Skip to content

Commit

Permalink
sort
Browse files Browse the repository at this point in the history
  • Loading branch information
megargayu committed Oct 6, 2022
1 parent c0cef94 commit 3ca010a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 166 deletions.
33 changes: 33 additions & 0 deletions contests/silver/2018/usopen/sort/sort.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <bits/stdc++.h>
using namespace std;

#define MAX_N 1e5
#define pii pair<int, int>

vector<pii> A(MAX_N);

int main()
{
ifstream fin("sort.in");
ofstream fout("sort.out");

int N;
fin >> N;

for (int i = 0; i < N; ++i)
{
fin >> A[i].first;
A[i].second = i;
}

sort(A.begin(), A.begin() + N, [](const pii &a, const pii &b)
{ return a.first == b.first ? a.second < b.second : a.first < b.first; });

int ans = 0;
for (int i = 0; i < N; ++i)
ans = max(ans, A[i].second - i);

fout << ans + 1 << '\n';

return 0;
}
6 changes: 6 additions & 0 deletions contests/silver/2018/usopen/sort/sort.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
5
1
5
3
8
2
1 change: 1 addition & 0 deletions contests/silver/2018/usopen/sort/sort.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4
166 changes: 0 additions & 166 deletions kattis/laneswitch/laneswitch.cpp

This file was deleted.

0 comments on commit 3ca010a

Please sign in to comment.