#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
using namespace std;
int n, i, a, b, w[2010000], c, S, R;
int main() {
cin >> n;
b = 0;
for (i = 1; i <= n; i++) {
cin >> a;
if (a > b) w[c++] = b * 2, w[c++] = a * 2 - 1;
b = a;
}
sort(w, w + c);
for (i = 0; i < c; i++) {
S += (w[i] & 1) ? -1 : 1;
if (R < S) R = S;
}
cout << R;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
760 KB |
Output is correct |
2 |
Correct |
35 ms |
936 KB |
Output is correct |
3 |
Correct |
35 ms |
888 KB |
Output is correct |
4 |
Correct |
35 ms |
1016 KB |
Output is correct |
5 |
Correct |
35 ms |
1016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
776 KB |
Output is correct |
2 |
Correct |
62 ms |
700 KB |
Output is correct |
3 |
Correct |
75 ms |
760 KB |
Output is correct |
4 |
Correct |
77 ms |
1532 KB |
Output is correct |
5 |
Correct |
74 ms |
1432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
803 ms |
12488 KB |
Output is correct |
2 |
Correct |
812 ms |
13592 KB |
Output is correct |
3 |
Correct |
819 ms |
13580 KB |
Output is correct |
4 |
Correct |
829 ms |
13696 KB |
Output is correct |
5 |
Correct |
779 ms |
13360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
782 ms |
11980 KB |
Output is correct |
2 |
Correct |
785 ms |
12868 KB |
Output is correct |
3 |
Correct |
781 ms |
12880 KB |
Output is correct |
4 |
Correct |
361 ms |
7084 KB |
Output is correct |
5 |
Correct |
366 ms |
7032 KB |
Output is correct |