# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1081371 |
2024-08-30T02:17:16 Z |
LCJLY |
Fish 2 (JOI22_fish2) |
C++14 |
|
11 ms |
4444 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << " " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << " " << j << " " << #i << " " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<int,int>pii;
typedef pair<pii,int>pi2;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
int arr[100005];
int prefix[100005];
void solve(){
int n;
cin >> n;
int lft[n+5];
int rgt[n+5];
for(int x=1;x<=n;x++){
cin >> arr[x];
prefix[x]=prefix[x-1]+arr[x];
lft[x]=rgt[x]=x;
}
int q;
cin >> q >> q >> q;
int counter=0;
for(int x=1;x<=n;x++){
while(lft[x]>1||rgt[x]<n){
if(lft[x]>1&&prefix[rgt[x]]-prefix[lft[x]-1]>=arr[lft[x]-1]){
//eat lft
int hold=lft[x]-1;
lft[x]=min(lft[x],lft[hold]);
rgt[x]=max(rgt[x],rgt[hold]);
}
else if(rgt[x]<n&&prefix[rgt[x]]-prefix[lft[x]-1]>=arr[rgt[x]+1]){
int hold=rgt[x]+1;
lft[x]=min(lft[x],lft[hold]);
rgt[x]=max(rgt[x],rgt[hold]);
}
else break;
}
if(lft[x]==1&&rgt[x]==n) counter++;
}
cout << counter << "\n";
}
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t=1;
//cin >> t;
//freopen("in.txt","r",stdin);
while(t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
8 ms |
3964 KB |
Output is correct |
3 |
Correct |
8 ms |
3676 KB |
Output is correct |
4 |
Correct |
8 ms |
3980 KB |
Output is correct |
5 |
Correct |
7 ms |
3676 KB |
Output is correct |
6 |
Correct |
10 ms |
4376 KB |
Output is correct |
7 |
Correct |
7 ms |
3676 KB |
Output is correct |
8 |
Correct |
10 ms |
4444 KB |
Output is correct |
9 |
Correct |
8 ms |
3544 KB |
Output is correct |
10 |
Correct |
11 ms |
3932 KB |
Output is correct |
11 |
Correct |
11 ms |
3676 KB |
Output is correct |
12 |
Correct |
8 ms |
3676 KB |
Output is correct |
13 |
Correct |
8 ms |
3676 KB |
Output is correct |
14 |
Correct |
8 ms |
3928 KB |
Output is correct |
15 |
Correct |
9 ms |
3932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
8 ms |
3964 KB |
Output is correct |
3 |
Correct |
8 ms |
3676 KB |
Output is correct |
4 |
Correct |
8 ms |
3980 KB |
Output is correct |
5 |
Correct |
7 ms |
3676 KB |
Output is correct |
6 |
Correct |
10 ms |
4376 KB |
Output is correct |
7 |
Correct |
7 ms |
3676 KB |
Output is correct |
8 |
Correct |
10 ms |
4444 KB |
Output is correct |
9 |
Correct |
8 ms |
3544 KB |
Output is correct |
10 |
Correct |
11 ms |
3932 KB |
Output is correct |
11 |
Correct |
11 ms |
3676 KB |
Output is correct |
12 |
Correct |
8 ms |
3676 KB |
Output is correct |
13 |
Correct |
8 ms |
3676 KB |
Output is correct |
14 |
Correct |
8 ms |
3928 KB |
Output is correct |
15 |
Correct |
9 ms |
3932 KB |
Output is correct |
16 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
8 ms |
3964 KB |
Output is correct |
3 |
Correct |
8 ms |
3676 KB |
Output is correct |
4 |
Correct |
8 ms |
3980 KB |
Output is correct |
5 |
Correct |
7 ms |
3676 KB |
Output is correct |
6 |
Correct |
10 ms |
4376 KB |
Output is correct |
7 |
Correct |
7 ms |
3676 KB |
Output is correct |
8 |
Correct |
10 ms |
4444 KB |
Output is correct |
9 |
Correct |
8 ms |
3544 KB |
Output is correct |
10 |
Correct |
11 ms |
3932 KB |
Output is correct |
11 |
Correct |
11 ms |
3676 KB |
Output is correct |
12 |
Correct |
8 ms |
3676 KB |
Output is correct |
13 |
Correct |
8 ms |
3676 KB |
Output is correct |
14 |
Correct |
8 ms |
3928 KB |
Output is correct |
15 |
Correct |
9 ms |
3932 KB |
Output is correct |
16 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |