Submission #951548

# Submission time Handle Problem Language Result Execution time Memory
951548 2024-03-22T05:58:32 Z pcc Fish 2 (JOI22_fish2) C++17
5 / 100
26 ms 1372 KB
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define fs first
#define sc second

const int mxn = 1e5+10;

int N,Q;
int arr[mxn];

namespace S1{

	int calc(vector<int> &v){
		int ans = 0;
		for(int i = 0;i<v.size();i++){
			int l = i,r = i;
			ll sum = v[i];
			while((l>0&&sum>=v[l-1])||(r+1<v.size()&&sum>=v[r+1])){
				if(l>0&&sum>=v[l-1]){
					l--;
					sum += v[l];
				}
				else{
					r++;
					sum += v[r];
				}
			}
			if(l == 0&&r+1 == v.size())ans++;
		}
		return ans;
	}

	void solve(){
		cin>>Q;
		while(Q--){
			int l,r,t;
			cin>>t>>l>>r;
			if(t == 1){
				arr[l] = r;
				continue;
			}
			vector<int> v;
			for(int i = l;i<=r;i++)v.push_back(arr[i]);
			cout<<calc(v)<<'\n';
		}
		return;
	}
}
namespace S2{
	void solve(){
	}
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>N;
	for(int i = 1;i<=N;i++)cin>>arr[i];
	if(N<=500&&Q<=500)S1::solve();
	else S2::solve();
}

Compilation message

fish2.cpp: In function 'int S1::calc(std::vector<int>&)':
fish2.cpp:19:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   for(int i = 0;i<v.size();i++){
      |                 ~^~~~~~~~~
fish2.cpp:22:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |    while((l>0&&sum>=v[l-1])||(r+1<v.size()&&sum>=v[r+1])){
      |                               ~~~^~~~~~~~~
fish2.cpp:32:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    if(l == 0&&r+1 == v.size())ans++;
      |               ~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 1 ms 472 KB Output is correct
9 Correct 7 ms 348 KB Output is correct
10 Correct 5 ms 348 KB Output is correct
11 Correct 14 ms 344 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 3 ms 472 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 10 ms 348 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 3 ms 484 KB Output is correct
20 Correct 26 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 7 ms 1372 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 1 ms 472 KB Output is correct
9 Correct 7 ms 348 KB Output is correct
10 Correct 5 ms 348 KB Output is correct
11 Correct 14 ms 344 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 3 ms 472 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 10 ms 348 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 3 ms 484 KB Output is correct
20 Correct 26 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Incorrect 7 ms 1372 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 7 ms 1372 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 7 ms 1372 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 1 ms 472 KB Output is correct
9 Correct 7 ms 348 KB Output is correct
10 Correct 5 ms 348 KB Output is correct
11 Correct 14 ms 344 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 3 ms 472 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 10 ms 348 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 3 ms 484 KB Output is correct
20 Correct 26 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Incorrect 7 ms 1372 KB Output isn't correct
23 Halted 0 ms 0 KB -