# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
596857 |
2022-07-15T08:05:21 Z |
이동현(#8450) |
Fish 2 (JOI22_fish2) |
C++17 |
|
4000 ms |
3876 KB |
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3")
#pragma GCC optimize9("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n; cin >> n;
vector<int> a(n);
for(int i = 0; i < n; ++i){
cin >> a[i];
}
int q; cin >> q;
while(q--){
int t, x, y; cin >> t >> x >> y;
if(t == 1){
--x;
a[x] = y;
}
else{
--x, --y;
vector<vector<int>> stk;
vector<int> ans;
stk.push_back({(int)1e9, x - 1, 0});
int sum = 0;
for(int i = x; i <= y; ++i){
while(stk.back()[0] < a[i]){
stk.pop_back();
}
if(sum - stk.back()[2] < a[i]){
while((int)ans.size() && ans.back() > stk.back()[1]){
ans.pop_back();
}
}
sum += a[i];
stk.push_back({a[i], i, sum});
ans.push_back(i);
}
vector<int> acnt(n);
for(auto&i:ans) ++acnt[i];
stk.clear(), ans.clear();
stk.push_back({(int)1e9, y + 1, 0});
sum = 0;
for(int i = y; i >= x; --i){
while(stk.back()[0] < a[i]){
stk.pop_back();
}
if(sum - stk.back()[2] < a[i]){
while((int)ans.size() && ans.back() < stk.back()[1]){
ans.pop_back();
}
}
sum += a[i];
stk.push_back({a[i], i, sum});
ans.push_back(i);
}
for(auto&i:ans) ++acnt[i];
int dap = 0;
for(int i = x; i <= y; ++i) dap += (acnt[i] == 2);
cout << dap << '\n';
}
}
return 0;
}
Compilation message
fish2.cpp:4: warning: ignoring '#pragma GCC optimize9' [-Wunknown-pragmas]
4 | #pragma GCC optimize9("Ofast")
|
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
212 KB |
Output is correct |
6 |
Correct |
6 ms |
212 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
5 ms |
212 KB |
Output is correct |
9 |
Correct |
8 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
9 ms |
336 KB |
Output is correct |
12 |
Correct |
3 ms |
340 KB |
Output is correct |
13 |
Correct |
7 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
5 ms |
340 KB |
Output is correct |
16 |
Correct |
9 ms |
336 KB |
Output is correct |
17 |
Correct |
3 ms |
212 KB |
Output is correct |
18 |
Correct |
8 ms |
324 KB |
Output is correct |
19 |
Correct |
4 ms |
340 KB |
Output is correct |
20 |
Correct |
19 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
15 ms |
3032 KB |
Output is correct |
3 |
Correct |
15 ms |
2004 KB |
Output is correct |
4 |
Correct |
16 ms |
2512 KB |
Output is correct |
5 |
Correct |
15 ms |
2016 KB |
Output is correct |
6 |
Correct |
20 ms |
2512 KB |
Output is correct |
7 |
Correct |
15 ms |
2136 KB |
Output is correct |
8 |
Correct |
20 ms |
2504 KB |
Output is correct |
9 |
Correct |
14 ms |
2132 KB |
Output is correct |
10 |
Correct |
16 ms |
1996 KB |
Output is correct |
11 |
Correct |
14 ms |
1892 KB |
Output is correct |
12 |
Correct |
15 ms |
2580 KB |
Output is correct |
13 |
Correct |
16 ms |
2640 KB |
Output is correct |
14 |
Correct |
17 ms |
2516 KB |
Output is correct |
15 |
Correct |
17 ms |
2512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
212 KB |
Output is correct |
6 |
Correct |
6 ms |
212 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
5 ms |
212 KB |
Output is correct |
9 |
Correct |
8 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
9 ms |
336 KB |
Output is correct |
12 |
Correct |
3 ms |
340 KB |
Output is correct |
13 |
Correct |
7 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
5 ms |
340 KB |
Output is correct |
16 |
Correct |
9 ms |
336 KB |
Output is correct |
17 |
Correct |
3 ms |
212 KB |
Output is correct |
18 |
Correct |
8 ms |
324 KB |
Output is correct |
19 |
Correct |
4 ms |
340 KB |
Output is correct |
20 |
Correct |
19 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
15 ms |
3032 KB |
Output is correct |
23 |
Correct |
15 ms |
2004 KB |
Output is correct |
24 |
Correct |
16 ms |
2512 KB |
Output is correct |
25 |
Correct |
15 ms |
2016 KB |
Output is correct |
26 |
Correct |
20 ms |
2512 KB |
Output is correct |
27 |
Correct |
15 ms |
2136 KB |
Output is correct |
28 |
Correct |
20 ms |
2504 KB |
Output is correct |
29 |
Correct |
14 ms |
2132 KB |
Output is correct |
30 |
Correct |
16 ms |
1996 KB |
Output is correct |
31 |
Correct |
14 ms |
1892 KB |
Output is correct |
32 |
Correct |
15 ms |
2580 KB |
Output is correct |
33 |
Correct |
16 ms |
2640 KB |
Output is correct |
34 |
Correct |
17 ms |
2516 KB |
Output is correct |
35 |
Correct |
17 ms |
2512 KB |
Output is correct |
36 |
Correct |
1177 ms |
2116 KB |
Output is correct |
37 |
Correct |
1834 ms |
2808 KB |
Output is correct |
38 |
Correct |
2276 ms |
2888 KB |
Output is correct |
39 |
Correct |
431 ms |
2116 KB |
Output is correct |
40 |
Correct |
2447 ms |
2708 KB |
Output is correct |
41 |
Correct |
2138 ms |
3016 KB |
Output is correct |
42 |
Correct |
2828 ms |
3092 KB |
Output is correct |
43 |
Correct |
2166 ms |
2276 KB |
Output is correct |
44 |
Correct |
2636 ms |
2388 KB |
Output is correct |
45 |
Correct |
1236 ms |
2024 KB |
Output is correct |
46 |
Correct |
1728 ms |
2608 KB |
Output is correct |
47 |
Correct |
2906 ms |
2780 KB |
Output is correct |
48 |
Correct |
826 ms |
2316 KB |
Output is correct |
49 |
Correct |
2772 ms |
2464 KB |
Output is correct |
50 |
Correct |
1497 ms |
3160 KB |
Output is correct |
51 |
Execution timed out |
4086 ms |
3272 KB |
Time limit exceeded |
52 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
15 ms |
3032 KB |
Output is correct |
3 |
Correct |
15 ms |
2004 KB |
Output is correct |
4 |
Correct |
16 ms |
2512 KB |
Output is correct |
5 |
Correct |
15 ms |
2016 KB |
Output is correct |
6 |
Correct |
20 ms |
2512 KB |
Output is correct |
7 |
Correct |
15 ms |
2136 KB |
Output is correct |
8 |
Correct |
20 ms |
2504 KB |
Output is correct |
9 |
Correct |
14 ms |
2132 KB |
Output is correct |
10 |
Correct |
16 ms |
1996 KB |
Output is correct |
11 |
Correct |
14 ms |
1892 KB |
Output is correct |
12 |
Correct |
15 ms |
2580 KB |
Output is correct |
13 |
Correct |
16 ms |
2640 KB |
Output is correct |
14 |
Correct |
17 ms |
2516 KB |
Output is correct |
15 |
Correct |
17 ms |
2512 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Execution timed out |
4096 ms |
2708 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
15 ms |
3032 KB |
Output is correct |
3 |
Correct |
15 ms |
2004 KB |
Output is correct |
4 |
Correct |
16 ms |
2512 KB |
Output is correct |
5 |
Correct |
15 ms |
2016 KB |
Output is correct |
6 |
Correct |
20 ms |
2512 KB |
Output is correct |
7 |
Correct |
15 ms |
2136 KB |
Output is correct |
8 |
Correct |
20 ms |
2504 KB |
Output is correct |
9 |
Correct |
14 ms |
2132 KB |
Output is correct |
10 |
Correct |
16 ms |
1996 KB |
Output is correct |
11 |
Correct |
14 ms |
1892 KB |
Output is correct |
12 |
Correct |
15 ms |
2580 KB |
Output is correct |
13 |
Correct |
16 ms |
2640 KB |
Output is correct |
14 |
Correct |
17 ms |
2516 KB |
Output is correct |
15 |
Correct |
17 ms |
2512 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Execution timed out |
4073 ms |
3876 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
212 KB |
Output is correct |
6 |
Correct |
6 ms |
212 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
5 ms |
212 KB |
Output is correct |
9 |
Correct |
8 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
9 ms |
336 KB |
Output is correct |
12 |
Correct |
3 ms |
340 KB |
Output is correct |
13 |
Correct |
7 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
5 ms |
340 KB |
Output is correct |
16 |
Correct |
9 ms |
336 KB |
Output is correct |
17 |
Correct |
3 ms |
212 KB |
Output is correct |
18 |
Correct |
8 ms |
324 KB |
Output is correct |
19 |
Correct |
4 ms |
340 KB |
Output is correct |
20 |
Correct |
19 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
15 ms |
3032 KB |
Output is correct |
23 |
Correct |
15 ms |
2004 KB |
Output is correct |
24 |
Correct |
16 ms |
2512 KB |
Output is correct |
25 |
Correct |
15 ms |
2016 KB |
Output is correct |
26 |
Correct |
20 ms |
2512 KB |
Output is correct |
27 |
Correct |
15 ms |
2136 KB |
Output is correct |
28 |
Correct |
20 ms |
2504 KB |
Output is correct |
29 |
Correct |
14 ms |
2132 KB |
Output is correct |
30 |
Correct |
16 ms |
1996 KB |
Output is correct |
31 |
Correct |
14 ms |
1892 KB |
Output is correct |
32 |
Correct |
15 ms |
2580 KB |
Output is correct |
33 |
Correct |
16 ms |
2640 KB |
Output is correct |
34 |
Correct |
17 ms |
2516 KB |
Output is correct |
35 |
Correct |
17 ms |
2512 KB |
Output is correct |
36 |
Correct |
1177 ms |
2116 KB |
Output is correct |
37 |
Correct |
1834 ms |
2808 KB |
Output is correct |
38 |
Correct |
2276 ms |
2888 KB |
Output is correct |
39 |
Correct |
431 ms |
2116 KB |
Output is correct |
40 |
Correct |
2447 ms |
2708 KB |
Output is correct |
41 |
Correct |
2138 ms |
3016 KB |
Output is correct |
42 |
Correct |
2828 ms |
3092 KB |
Output is correct |
43 |
Correct |
2166 ms |
2276 KB |
Output is correct |
44 |
Correct |
2636 ms |
2388 KB |
Output is correct |
45 |
Correct |
1236 ms |
2024 KB |
Output is correct |
46 |
Correct |
1728 ms |
2608 KB |
Output is correct |
47 |
Correct |
2906 ms |
2780 KB |
Output is correct |
48 |
Correct |
826 ms |
2316 KB |
Output is correct |
49 |
Correct |
2772 ms |
2464 KB |
Output is correct |
50 |
Correct |
1497 ms |
3160 KB |
Output is correct |
51 |
Execution timed out |
4086 ms |
3272 KB |
Time limit exceeded |
52 |
Halted |
0 ms |
0 KB |
- |