답안 #492580

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
492580 2021-12-08T02:48:05 Z Deepesson Feast (NOI19_feast) C++17
100 / 100
113 ms 5700 KB
#include <bits/stdc++.h>
#define MAX 505000
int N,K;
long long array[MAX];
typedef std::pair<long long,long long> pll;
pll func(long long C){
    long long a=1,b=0;
    long long max=0,maxval=0;
    long long pega=-C,npega=0;
    for(int i=0;i!=N;++i){
        pega+=array[i];
        if(pega>npega){
            npega=pega;
            b=a;
        }
        if(npega-C>pega){
            pega=npega-C;
            a=b;
            ++a;
        }
        if(pega>max){
            max=pega;
            maxval=a;
        }
    }
    return {max,maxval};
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    std::cin>>N>>K;
    for(int i=0;i!=N;++i)std::cin>>array[i];
    long long l=0,r=1LL<<50LL;
    while(l<r){
        long long m = (l+r)/2;
        long long res = func(m).second;
        if(res<=K){
            r=m;
        }else l=m+1;
    }
    auto res = func(l);
    if(!l){
        std::cout<<res.first<<"\n";
        return 0;
    }
    std::cout<<(res.first+(K*l))<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 2576 KB Output is correct
2 Correct 45 ms 5400 KB Output is correct
3 Correct 44 ms 5444 KB Output is correct
4 Correct 49 ms 5444 KB Output is correct
5 Correct 43 ms 5456 KB Output is correct
6 Correct 43 ms 5316 KB Output is correct
7 Correct 42 ms 5292 KB Output is correct
8 Correct 51 ms 5416 KB Output is correct
9 Correct 44 ms 5332 KB Output is correct
10 Correct 43 ms 5436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 2508 KB Output is correct
2 Correct 37 ms 2636 KB Output is correct
3 Correct 43 ms 2484 KB Output is correct
4 Correct 34 ms 2564 KB Output is correct
5 Correct 42 ms 5280 KB Output is correct
6 Correct 38 ms 3660 KB Output is correct
7 Correct 35 ms 3776 KB Output is correct
8 Correct 42 ms 5424 KB Output is correct
9 Correct 47 ms 5340 KB Output is correct
10 Correct 35 ms 3748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 2664 KB Output is correct
2 Correct 69 ms 2536 KB Output is correct
3 Correct 69 ms 2536 KB Output is correct
4 Correct 70 ms 2508 KB Output is correct
5 Correct 71 ms 2612 KB Output is correct
6 Correct 72 ms 2568 KB Output is correct
7 Correct 70 ms 2636 KB Output is correct
8 Correct 77 ms 2588 KB Output is correct
9 Correct 69 ms 2672 KB Output is correct
10 Correct 71 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 2576 KB Output is correct
2 Correct 45 ms 5400 KB Output is correct
3 Correct 44 ms 5444 KB Output is correct
4 Correct 49 ms 5444 KB Output is correct
5 Correct 43 ms 5456 KB Output is correct
6 Correct 43 ms 5316 KB Output is correct
7 Correct 42 ms 5292 KB Output is correct
8 Correct 51 ms 5416 KB Output is correct
9 Correct 44 ms 5332 KB Output is correct
10 Correct 43 ms 5436 KB Output is correct
11 Correct 37 ms 2508 KB Output is correct
12 Correct 37 ms 2636 KB Output is correct
13 Correct 43 ms 2484 KB Output is correct
14 Correct 34 ms 2564 KB Output is correct
15 Correct 42 ms 5280 KB Output is correct
16 Correct 38 ms 3660 KB Output is correct
17 Correct 35 ms 3776 KB Output is correct
18 Correct 42 ms 5424 KB Output is correct
19 Correct 47 ms 5340 KB Output is correct
20 Correct 35 ms 3748 KB Output is correct
21 Correct 70 ms 2664 KB Output is correct
22 Correct 69 ms 2536 KB Output is correct
23 Correct 69 ms 2536 KB Output is correct
24 Correct 70 ms 2508 KB Output is correct
25 Correct 71 ms 2612 KB Output is correct
26 Correct 72 ms 2568 KB Output is correct
27 Correct 70 ms 2636 KB Output is correct
28 Correct 77 ms 2588 KB Output is correct
29 Correct 69 ms 2672 KB Output is correct
30 Correct 71 ms 2636 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 0 ms 204 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 0 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 0 ms 204 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 336 KB Output is correct
55 Correct 1 ms 332 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 2 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 332 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 113 ms 5572 KB Output is correct
62 Correct 103 ms 5588 KB Output is correct
63 Correct 87 ms 5464 KB Output is correct
64 Correct 111 ms 5700 KB Output is correct
65 Correct 112 ms 5664 KB Output is correct
66 Correct 108 ms 5648 KB Output is correct
67 Correct 113 ms 5564 KB Output is correct
68 Correct 72 ms 5632 KB Output is correct
69 Correct 75 ms 5700 KB Output is correct
70 Correct 69 ms 5416 KB Output is correct