/*
doing virtual contest
start: 10:00
finish: 14:00
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
vector<int> countScans(vector<int> a, vector<int> x, vector<int> v) {
int n = (int)a.size(), q = (int)x.size();
vector<int> ret;
for (int j = 0; j < q; ++j) {
a[x[j]] = v[j];
vector<pair<int, int>> srt;
for (int i = 0; i < n; ++i) srt.push_back({a[i], i});
sort(srt.begin(), srt.end());
vector<int> p(n);
for (int i = 0; i < n; ++i) p[srt[i].second] = i;
/*for (int i = 0; i < n; ++i) cout << a[i] << " ";
cout << '\n';
for (int i = 0; i < n; ++i) cout << p[i] << " ";
cout << '\n';*/
int ans = 0;
for (int i = 0; i < n; ++i) ans = max(ans, i - p[i]);
ret.push_back(ans);
}
return ret;
}
#ifdef LOCAL
int main() {
freopen("input.txt", "r", stdin);
ios::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n >> q;
vector<int> a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
vector<int> x(q), v(q);
for (int i = 0; i < q; ++i) cin >> x[i] >> v[i];
auto s = countScans(a, x, v);
for (int i = 0; i < q; ++i) cout << s[i] << '\n';
return 0;
}
#endif
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
364 KB |
Output is correct |
2 |
Correct |
43 ms |
364 KB |
Output is correct |
3 |
Correct |
259 ms |
620 KB |
Output is correct |
4 |
Correct |
259 ms |
620 KB |
Output is correct |
5 |
Correct |
247 ms |
620 KB |
Output is correct |
6 |
Correct |
174 ms |
492 KB |
Output is correct |
7 |
Correct |
211 ms |
492 KB |
Output is correct |
8 |
Correct |
238 ms |
624 KB |
Output is correct |
9 |
Correct |
246 ms |
628 KB |
Output is correct |
10 |
Correct |
162 ms |
492 KB |
Output is correct |
11 |
Correct |
158 ms |
620 KB |
Output is correct |
12 |
Correct |
161 ms |
492 KB |
Output is correct |
13 |
Correct |
158 ms |
492 KB |
Output is correct |
14 |
Correct |
156 ms |
492 KB |
Output is correct |
15 |
Correct |
157 ms |
640 KB |
Output is correct |
16 |
Correct |
148 ms |
492 KB |
Output is correct |
17 |
Correct |
146 ms |
492 KB |
Output is correct |
18 |
Correct |
142 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
364 KB |
Output is correct |
2 |
Correct |
43 ms |
364 KB |
Output is correct |
3 |
Correct |
259 ms |
620 KB |
Output is correct |
4 |
Correct |
259 ms |
620 KB |
Output is correct |
5 |
Correct |
247 ms |
620 KB |
Output is correct |
6 |
Correct |
174 ms |
492 KB |
Output is correct |
7 |
Correct |
211 ms |
492 KB |
Output is correct |
8 |
Correct |
238 ms |
624 KB |
Output is correct |
9 |
Correct |
246 ms |
628 KB |
Output is correct |
10 |
Correct |
162 ms |
492 KB |
Output is correct |
11 |
Correct |
158 ms |
620 KB |
Output is correct |
12 |
Correct |
161 ms |
492 KB |
Output is correct |
13 |
Correct |
158 ms |
492 KB |
Output is correct |
14 |
Correct |
156 ms |
492 KB |
Output is correct |
15 |
Correct |
157 ms |
640 KB |
Output is correct |
16 |
Correct |
148 ms |
492 KB |
Output is correct |
17 |
Correct |
146 ms |
492 KB |
Output is correct |
18 |
Correct |
142 ms |
620 KB |
Output is correct |
19 |
Correct |
3708 ms |
988 KB |
Output is correct |
20 |
Correct |
4906 ms |
1144 KB |
Output is correct |
21 |
Correct |
4195 ms |
1140 KB |
Output is correct |
22 |
Correct |
4740 ms |
924 KB |
Output is correct |
23 |
Correct |
2987 ms |
900 KB |
Output is correct |
24 |
Correct |
2974 ms |
892 KB |
Output is correct |
25 |
Correct |
2944 ms |
904 KB |
Output is correct |
26 |
Correct |
2998 ms |
896 KB |
Output is correct |
27 |
Correct |
2989 ms |
988 KB |
Output is correct |
28 |
Correct |
2879 ms |
1004 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6340 ms |
1424 KB |
Output is correct |
2 |
Execution timed out |
9022 ms |
2732 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
364 KB |
Output is correct |
2 |
Correct |
43 ms |
364 KB |
Output is correct |
3 |
Correct |
259 ms |
620 KB |
Output is correct |
4 |
Correct |
259 ms |
620 KB |
Output is correct |
5 |
Correct |
247 ms |
620 KB |
Output is correct |
6 |
Correct |
174 ms |
492 KB |
Output is correct |
7 |
Correct |
211 ms |
492 KB |
Output is correct |
8 |
Correct |
238 ms |
624 KB |
Output is correct |
9 |
Correct |
246 ms |
628 KB |
Output is correct |
10 |
Correct |
162 ms |
492 KB |
Output is correct |
11 |
Correct |
158 ms |
620 KB |
Output is correct |
12 |
Correct |
161 ms |
492 KB |
Output is correct |
13 |
Correct |
158 ms |
492 KB |
Output is correct |
14 |
Correct |
156 ms |
492 KB |
Output is correct |
15 |
Correct |
157 ms |
640 KB |
Output is correct |
16 |
Correct |
148 ms |
492 KB |
Output is correct |
17 |
Correct |
146 ms |
492 KB |
Output is correct |
18 |
Correct |
142 ms |
620 KB |
Output is correct |
19 |
Correct |
3708 ms |
988 KB |
Output is correct |
20 |
Correct |
4906 ms |
1144 KB |
Output is correct |
21 |
Correct |
4195 ms |
1140 KB |
Output is correct |
22 |
Correct |
4740 ms |
924 KB |
Output is correct |
23 |
Correct |
2987 ms |
900 KB |
Output is correct |
24 |
Correct |
2974 ms |
892 KB |
Output is correct |
25 |
Correct |
2944 ms |
904 KB |
Output is correct |
26 |
Correct |
2998 ms |
896 KB |
Output is correct |
27 |
Correct |
2989 ms |
988 KB |
Output is correct |
28 |
Correct |
2879 ms |
1004 KB |
Output is correct |
29 |
Correct |
6340 ms |
1424 KB |
Output is correct |
30 |
Execution timed out |
9022 ms |
2732 KB |
Time limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |