# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
903831 |
2024-01-11T11:58:46 Z |
LucaIlie |
Fish 2 (JOI22_fish2) |
C++17 |
|
557 ms |
3156 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5;
int v[MAX_N + 1], leftt[MAX_N + 1], rightt[MAX_N + 1];
bool baul[MAX_N + 1], baur[MAX_N + 1];
long long s[MAX_N + 1];
int main() {
int n;
cin >> n;
for ( int i = 1; i <= n; i++ ) {
cin >> v[i];
s[i] = s[i - 1] + v[i];
}
for ( int i = 1; i < n; i++ ) {
int l = 0, r = i + 1;
while ( r - l > 1 ) {
int mid = (l + r) / 2;
if ( s[i] - s[mid - 1] >= v[i + 1] )
l = mid;
else
r = mid;
}
leftt[i] = l;
}
for ( int i = 2; i <= n; i++ ) {
int l = i - 1, r = n + 1;
while ( r - l > 1 ) {
int mid = (l + r) / 2;
if ( s[mid] - s[i - 1] >= v[i - 1] )
r = mid;
else
l = mid;
}
rightt[i] = r;
}
for ( int i = 1; i < n; i++ ) {
if ( leftt[i] == 0 )
baul[i] = 0;
else
baul[i] = (rightt[leftt[i] + 1] <= i);
}
for ( int i = 2; i <= n; i++ ) {
if ( rightt[i] == n + 1 )
baur[i] = 0;
else
baur[i] = (leftt[rightt[i] - 1] >= i);
}
int ans = 0;
for ( int i = 1; i <= n; i++ ) {
int p;
p = i;
while ( p >= 2 && (rightt[p] <= i || baur[p]) )
p--;
if ( p != 1 )
continue;
p = n;
while ( p <= n - 1 && (leftt[p] >= i || baul[p]) )
p++;
if ( p == n )
ans++;
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
356 KB |
Output is correct |
2 |
Incorrect |
557 ms |
3156 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
356 KB |
Output is correct |
2 |
Incorrect |
557 ms |
3156 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
356 KB |
Output is correct |
2 |
Incorrect |
557 ms |
3156 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |