# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
983790 |
2024-05-16T06:11:59 Z |
LucaIlie |
Hacker (BOI15_hac) |
C++17 |
|
456 ms |
2396 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 5e5;
int v[MAX_N + 1], sp[MAX_N + 1];
int main() {
int n;
cin >> n;
for ( int i = 1; i <= n; i++ ) {
cin >> v[i];
sp[i] = sp[i - 1] + v[i];
}
int maxx = 0;
for ( int i = 1; i <= n; i++ ) {
int minn = 1e9;
for ( int j = 1; j <= n; j++ ) {
if ( i == j )
continue;
int l, r;
vector<int> v1, v2;
l = i % n + 1;
while ( l != j ) {
v1.push_back( v[l] );
l = l % n + 1;
}
l = j % n + 1;
while ( l != i ) {
v2.push_back( v[l] );
l = l % n + 1;
}
reverse( v2.begin(), v2.end() );
int l1 = 0, r1 = v1.size() - 1;
int l2 = 0, r2 = v2.size() - 1;
int s = 0, p = 0;
while ( l1 <= r1 || l2 <= r2 ) {
if ( p == 0 ) {
if ( l2 > r2 || (l1 <= r1 && v1[l1] > v2[l2]) ) {
s += v1[l1];
l1++;
} else {
s += v2[l2];
l2++;
}
} else {
if ( l2 > r2 || (l1 <= r1 && v2[r1] > v2[r2]) ) {
s += v1[r1];
r1--;
} else {
s += v2[r2];
r2--;
}
}
p ^= 1;
}
minn = min( minn, s );
}
maxx = max( maxx, minn );
}
cout << maxx;
return 0;
}
Compilation message
hac.cpp: In function 'int main()':
hac.cpp:24:20: warning: unused variable 'r' [-Wunused-variable]
24 | int l, r;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
456 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |