Submission #761613

# Submission time Handle Problem Language Result Execution time Memory
761613 2023-06-20T05:33:43 Z gggkik None (JOI14_ho_t3) C++14
100 / 100
247 ms 7508 KB
#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e5+5;
#define ll long long
ll A[MXN], P[MXN], n, all;
vector<ll> sa, sb;
ll cut(ll x,int i){
    return all-
        *lower_bound(sa.begin(),sa.end(),x+P[i])-
        *lower_bound(sb.begin(),sb.end(),x-P[i]);
}
int f(ll x){ // 답이 x 이상인가?
    for(int i = 0;i<n;i++) // i에서 cut
        if(cut(x,i)>=x) return 1;
    return 0;
}
ll sum(int i,int j){return (i<=j?P[j]-P[i-1]:0);}
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    for(int i = 1;i<=n;i++){
        cin >> A[i]; P[i] = P[i-1]+A[i];
    }
    all = P[n];
    ll suma = 0, sumb = 0;
    sa.push_back(0);
    for(int t = 0;t<2;t++)
        for(int i = 1;i<=n;i++){
            suma += A[i]; sa.push_back(suma);
        }
    for(int i = n;i>0;i--){
        sumb += A[i]; sb.push_back(sumb);
    }
    for(int i = 0;i<=n;i++) sb.push_back(-P[i]);
    sort(sb.begin(),sb.end());
    ll l = 0, r = all;
    for(;l+1<r;){
        ll mid = l+r>>1;
        if(f(mid)) l = mid;
        else r = mid;
    }
    cout << l;
}

Compilation message

2014_ho_t3.cpp: In function 'int main()':
2014_ho_t3.cpp:38:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   38 |         ll mid = l+r>>1;
      |                  ~^~
# 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 13 ms 852 KB Output is correct
22 Correct 11 ms 852 KB Output is correct
23 Correct 11 ms 852 KB Output is correct
24 Correct 11 ms 852 KB Output is correct
25 Correct 11 ms 852 KB Output is correct
26 Correct 15 ms 852 KB Output is correct
27 Correct 18 ms 856 KB Output is correct
28 Correct 16 ms 852 KB Output is correct
29 Correct 17 ms 852 KB Output is correct
30 Correct 18 ms 852 KB Output is correct
31 Correct 7 ms 852 KB Output is correct
32 Correct 8 ms 852 KB Output is correct
33 Correct 8 ms 852 KB Output is correct
34 Correct 7 ms 852 KB Output is correct
35 Correct 7 ms 852 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 13 ms 852 KB Output is correct
22 Correct 11 ms 852 KB Output is correct
23 Correct 11 ms 852 KB Output is correct
24 Correct 11 ms 852 KB Output is correct
25 Correct 11 ms 852 KB Output is correct
26 Correct 15 ms 852 KB Output is correct
27 Correct 18 ms 856 KB Output is correct
28 Correct 16 ms 852 KB Output is correct
29 Correct 17 ms 852 KB Output is correct
30 Correct 18 ms 852 KB Output is correct
31 Correct 7 ms 852 KB Output is correct
32 Correct 8 ms 852 KB Output is correct
33 Correct 8 ms 852 KB Output is correct
34 Correct 7 ms 852 KB Output is correct
35 Correct 7 ms 852 KB Output is correct
36 Correct 216 ms 7456 KB Output is correct
37 Correct 244 ms 7508 KB Output is correct
38 Correct 238 ms 7380 KB Output is correct
39 Correct 246 ms 7500 KB Output is correct
40 Correct 228 ms 7500 KB Output is correct
41 Correct 247 ms 7496 KB Output is correct
42 Correct 204 ms 7492 KB Output is correct
43 Correct 237 ms 7504 KB Output is correct
44 Correct 192 ms 7436 KB Output is correct
45 Correct 243 ms 7500 KB Output is correct
46 Correct 102 ms 6732 KB Output is correct
47 Correct 98 ms 6732 KB Output is correct
48 Correct 106 ms 6628 KB Output is correct