# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
537320 |
2022-03-15T01:09:40 Z |
crystaalroo |
Hacker (BOI15_hac) |
C++14 |
|
420 ms |
20312 KB |
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
long long gcd(long long a, long long b){ return b? gcd(b, a%b) : a; }
long long lcm(long long a, long long b){ return (!a or !b)? 0 : a * b / gcd(a,b); }
long long poww(long long a, long long b){
long long res = 1;
while(b){
if(b%2) res = res * a ;
a = a * a; b>>=1;
} return res;
}
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int rnd(int n){return uniform_int_distribution<int>(0, n-1)(rng);}
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
template<class t,class u>bool mmax(t&a,u b){if(a<b)a=b;return a<b;}
template<class t,class u>bool mmin(t&a,u b){if(b<a)a=b;return b<a;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using li = long long;
using vi = vc<int>;
using ii = pair<int,int>;
// ('-')7
int main(){_
auto solve=[&](){
int n; cin>>n;
vi v(2*n+1); fore(i,0,n)cin>>v[i+1],v[i+n+1]=v[i+1];
fore(i,1,2*n+1)v[i]+=v[i-1];
multiset<int>s;
int best = -1, u = (n+1)/2;
vi res(n+1,inf<int>);
fore(i,1,2*n+1){
if(i+u-1<=2*n)s.insert(v[i+u-1]-v[i-1]);
if(i>u)s.erase(s.find(v[i-1]-v[i-u-1]));
int prev = ((i-1)%n)+1;
res[prev]=min(res[prev],*s.begin());
}
fore(i,1,n+1)best = max(best,res[i]);
cout<<best<<ENDL;
};
//int t; cin>>t; while(t--)
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
320 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
324 KB |
Output is correct |
15 |
Correct |
1 ms |
316 KB |
Output is correct |
16 |
Correct |
1 ms |
320 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
320 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
324 KB |
Output is correct |
15 |
Correct |
1 ms |
316 KB |
Output is correct |
16 |
Correct |
1 ms |
320 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
316 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
3 ms |
520 KB |
Output is correct |
24 |
Correct |
2 ms |
328 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
3 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
316 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
3 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
468 KB |
Output is correct |
4 |
Correct |
37 ms |
3488 KB |
Output is correct |
5 |
Correct |
114 ms |
8120 KB |
Output is correct |
6 |
Correct |
166 ms |
10328 KB |
Output is correct |
7 |
Correct |
175 ms |
12236 KB |
Output is correct |
8 |
Correct |
420 ms |
20104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
320 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
324 KB |
Output is correct |
15 |
Correct |
1 ms |
316 KB |
Output is correct |
16 |
Correct |
1 ms |
320 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
316 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
3 ms |
520 KB |
Output is correct |
24 |
Correct |
2 ms |
328 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
3 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
316 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
3 ms |
468 KB |
Output is correct |
32 |
Correct |
0 ms |
212 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
3 ms |
468 KB |
Output is correct |
35 |
Correct |
37 ms |
3488 KB |
Output is correct |
36 |
Correct |
114 ms |
8120 KB |
Output is correct |
37 |
Correct |
166 ms |
10328 KB |
Output is correct |
38 |
Correct |
175 ms |
12236 KB |
Output is correct |
39 |
Correct |
420 ms |
20104 KB |
Output is correct |
40 |
Correct |
5 ms |
596 KB |
Output is correct |
41 |
Correct |
9 ms |
1100 KB |
Output is correct |
42 |
Correct |
14 ms |
1492 KB |
Output is correct |
43 |
Correct |
116 ms |
8140 KB |
Output is correct |
44 |
Correct |
332 ms |
20208 KB |
Output is correct |
45 |
Correct |
47 ms |
4172 KB |
Output is correct |
46 |
Correct |
176 ms |
12280 KB |
Output is correct |
47 |
Correct |
315 ms |
20108 KB |
Output is correct |
48 |
Correct |
251 ms |
20312 KB |
Output is correct |
49 |
Correct |
251 ms |
19504 KB |
Output is correct |
50 |
Correct |
222 ms |
19508 KB |
Output is correct |