답안 #1081361

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1081361 2024-08-30T01:56:05 Z thelegendary08 Fish 2 (JOI22_fish2) C++14
0 / 100
395 ms 2396 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 == 0){
						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';
			
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 2 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 395 ms 2396 KB Output is correct
3 Incorrect 39 ms 2140 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 2 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 395 ms 2396 KB Output is correct
3 Incorrect 39 ms 2140 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 395 ms 2396 KB Output is correct
3 Incorrect 39 ms 2140 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 2 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -