#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() {
ios_base::sync_with_stdio(0);
cin.tie(0);
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 |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
732 KB |
Output is correct |
2 |
Correct |
14 ms |
760 KB |
Output is correct |
3 |
Correct |
14 ms |
760 KB |
Output is correct |
4 |
Correct |
14 ms |
760 KB |
Output is correct |
5 |
Correct |
14 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
760 KB |
Output is correct |
2 |
Correct |
19 ms |
760 KB |
Output is correct |
3 |
Correct |
24 ms |
792 KB |
Output is correct |
4 |
Correct |
24 ms |
780 KB |
Output is correct |
5 |
Correct |
23 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
249 ms |
4344 KB |
Output is correct |
2 |
Correct |
248 ms |
4344 KB |
Output is correct |
3 |
Correct |
250 ms |
4300 KB |
Output is correct |
4 |
Correct |
249 ms |
4344 KB |
Output is correct |
5 |
Correct |
238 ms |
4472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
238 ms |
4252 KB |
Output is correct |
2 |
Correct |
237 ms |
4216 KB |
Output is correct |
3 |
Correct |
238 ms |
4276 KB |
Output is correct |
4 |
Correct |
132 ms |
4216 KB |
Output is correct |
5 |
Correct |
137 ms |
4188 KB |
Output is correct |