Submission #555858

# Submission time Handle Problem Language Result Execution time Memory
555858 2022-05-01T17:52:43 Z Arvin Fish 2 (JOI22_fish2) C++11
5 / 100
4000 ms 1552 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	
	int n;
	cin >> n;
	
	int a[n];
	for(int x=0;x<n;x++){
		cin >> a[x];
	}
	
	int q;
	cin >> q;
	
	while(q--){
		int t;
		cin >> t;
		
		if(t == 1){
			int pos, val;
			cin >> pos >> val;
			
			pos--;
			a[pos] = val;
		} else if(t == 2){
			int l, r;
			cin >> l >> r;
			
			l--; r--;
			
			int ans = 0;
			for(int x=l;x<=r;x++){
				ll sum = a[x];
				int left = x-1, right = x+1;
				while(left >= l && right <= r){
					if(a[left] <= a[right]){
						if(a[left] > sum) break;
						sum += a[left--];
					} else {
						if(a[right] > sum) break;
						sum += a[right++];
					}
				}
				while(left >= l){
					if(a[left] > sum) break;
					sum += a[left--];
				}
				while(right <= r){
					if(a[right] > sum) break;
					sum += a[right++];
				}
				
				if(left == l-1 && right == r+1){
					ans++;
				}
			}
			
			cout << ans << "\n";
		} else {
			assert(false);
		}
	}
	
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 3 ms 320 KB Output is correct
6 Correct 3 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 6 ms 324 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
11 Correct 12 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 4 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
16 Correct 10 ms 340 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 5 ms 212 KB Output is correct
19 Correct 4 ms 212 KB Output is correct
20 Correct 28 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 320 KB Output is correct
2 Correct 515 ms 1228 KB Output is correct
3 Correct 52 ms 1008 KB Output is correct
4 Correct 480 ms 1264 KB Output is correct
5 Correct 58 ms 1028 KB Output is correct
6 Execution timed out 4057 ms 1552 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 3 ms 320 KB Output is correct
6 Correct 3 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 6 ms 324 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
11 Correct 12 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 4 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
16 Correct 10 ms 340 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 5 ms 212 KB Output is correct
19 Correct 4 ms 212 KB Output is correct
20 Correct 28 ms 212 KB Output is correct
21 Correct 0 ms 320 KB Output is correct
22 Correct 515 ms 1228 KB Output is correct
23 Correct 52 ms 1008 KB Output is correct
24 Correct 480 ms 1264 KB Output is correct
25 Correct 58 ms 1028 KB Output is correct
26 Execution timed out 4057 ms 1552 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 320 KB Output is correct
2 Correct 515 ms 1228 KB Output is correct
3 Correct 52 ms 1008 KB Output is correct
4 Correct 480 ms 1264 KB Output is correct
5 Correct 58 ms 1028 KB Output is correct
6 Execution timed out 4057 ms 1552 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 320 KB Output is correct
2 Correct 515 ms 1228 KB Output is correct
3 Correct 52 ms 1008 KB Output is correct
4 Correct 480 ms 1264 KB Output is correct
5 Correct 58 ms 1028 KB Output is correct
6 Execution timed out 4057 ms 1552 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 3 ms 320 KB Output is correct
6 Correct 3 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 6 ms 324 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
11 Correct 12 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 4 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
16 Correct 10 ms 340 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 5 ms 212 KB Output is correct
19 Correct 4 ms 212 KB Output is correct
20 Correct 28 ms 212 KB Output is correct
21 Correct 0 ms 320 KB Output is correct
22 Correct 515 ms 1228 KB Output is correct
23 Correct 52 ms 1008 KB Output is correct
24 Correct 480 ms 1264 KB Output is correct
25 Correct 58 ms 1028 KB Output is correct
26 Execution timed out 4057 ms 1552 KB Time limit exceeded
27 Halted 0 ms 0 KB -