Submission #1081363

# Submission time Handle Problem Language Result Execution time Memory
1081363 2024-08-30T02:00:11 Z thelegendary08 Fish 2 (JOI22_fish2) C++14
5 / 100
4000 ms 2904 KB
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define mii map<int,int>
#define mll map<long long int, long long int>
#define mivi map<int,vector<int>>
#define f0r(i,n) for(int i=0;i<n;i++)
#define FOR(i,k,n) for(int i=k;i<n;i++)
using namespace std;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//ifstream cin(".in");
	//ofstream cout(".out");
	int n;
	cin>>n;
	vi w(n);
	f0r(i,n)cin>>w[i];
	
	int q;
	cin>>q;
	while(q--){
		int type;
		cin>>type;
		if(type == 1){
			int k,x;
			cin>>k>>x;
			k--;
			w[k] = x;
		}
		else{
			int l, r;
			cin>>l>>r;
			l--;
			r--;
			int m = r - l + 1;
			vi v(m);
			
			for(int i = l; i <= r; i++){
				v[i - l] = w[i];
			}
			
			int ans = 0;
			f0r(i,m){
				pii t = {i, i};
				int s = v[i];
				int sz = 1;
				while(sz != m){
					if(t.first == 0){
						if(v[t.second + 1] > s)break;
						else{
							t.second++;
							sz++;
							s += v[t.second];
						}
					}
					else if(t.second == m-1){
						if(v[t.first - 1] > s)break;
						else{
							t.first--;
							sz++;
							s += v[t.first];
						}
					}
					else{
						if(v[t.second + 1] <= s){
							t.second++;
							sz++;
							s += v[t.second];
						}
						else if(v[t.first - 1] <= s){
							t.first--;
							sz++;
							s += v[t.first];
						}
						else{
							break;
						}
					}
				}
				if(sz == m)ans++;
			}
			cout<<ans<<'\n';
			
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 3 ms 480 KB Output is correct
7 Correct 2 ms 616 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 5 ms 348 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 10 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 6 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 3 ms 348 KB Output is correct
20 Correct 23 ms 476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 463 ms 1884 KB Output is correct
3 Correct 48 ms 1884 KB Output is correct
4 Correct 452 ms 2392 KB Output is correct
5 Correct 51 ms 2132 KB Output is correct
6 Execution timed out 4010 ms 2904 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 3 ms 480 KB Output is correct
7 Correct 2 ms 616 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 5 ms 348 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 10 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 6 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 3 ms 348 KB Output is correct
20 Correct 23 ms 476 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 463 ms 1884 KB Output is correct
23 Correct 48 ms 1884 KB Output is correct
24 Correct 452 ms 2392 KB Output is correct
25 Correct 51 ms 2132 KB Output is correct
26 Execution timed out 4010 ms 2904 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 463 ms 1884 KB Output is correct
3 Correct 48 ms 1884 KB Output is correct
4 Correct 452 ms 2392 KB Output is correct
5 Correct 51 ms 2132 KB Output is correct
6 Execution timed out 4010 ms 2904 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 463 ms 1884 KB Output is correct
3 Correct 48 ms 1884 KB Output is correct
4 Correct 452 ms 2392 KB Output is correct
5 Correct 51 ms 2132 KB Output is correct
6 Execution timed out 4010 ms 2904 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 3 ms 480 KB Output is correct
7 Correct 2 ms 616 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 5 ms 348 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 10 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 6 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 3 ms 348 KB Output is correct
20 Correct 23 ms 476 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 463 ms 1884 KB Output is correct
23 Correct 48 ms 1884 KB Output is correct
24 Correct 452 ms 2392 KB Output is correct
25 Correct 51 ms 2132 KB Output is correct
26 Execution timed out 4010 ms 2904 KB Time limit exceeded
27 Halted 0 ms 0 KB -