답안 #1025801

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1025801 2024-07-17T10:15:13 Z ach00 Feast (NOI19_feast) C++14
100 / 100
854 ms 24188 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MP make_pair
#define EPS 0.00001
int n,k;
vector<ll> W;
pair<ll,ll> solve(ll pen) {
    vector<vector<pair<ll,ll>>> dp(300005, vector<pair<ll,ll>>(2));
    dp[0][0] = {0, 0};
    dp[0][1] = {W[0] - pen, 1};
    for(int i = 1; i < n; i++) {
        dp[i][0] = max(dp[i-1][0], dp[i-1][1]);
        dp[i][1] = max(MP(dp[i-1][1].first + W[i], dp[i-1][1].second), MP(dp[i-1][0].first + W[i] - pen, dp[i-1][0].second + 1));
    }
    return max(dp[n-1][0], dp[n-1][1]);
}

int main() {
    cin >> n >> k;
    ll lower = 0;
    ll upper = 1000000000000000;
    W.resize(n); for(auto &a : W) cin >> a;
    while(lower < upper) {
        ll m = (lower+upper+1)/2;
        auto K = solve(m);
        if(K.second >= k) {
            lower = m;
        } else {
            upper = m-1;
        }
    }
    auto K = solve(lower);
    cout << K.first + k*lower;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 677 ms 23868 KB Output is correct
2 Correct 694 ms 23932 KB Output is correct
3 Correct 688 ms 23976 KB Output is correct
4 Correct 706 ms 24188 KB Output is correct
5 Correct 664 ms 23948 KB Output is correct
6 Correct 725 ms 23920 KB Output is correct
7 Correct 690 ms 23892 KB Output is correct
8 Correct 695 ms 23928 KB Output is correct
9 Correct 706 ms 24052 KB Output is correct
10 Correct 706 ms 23928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 692 ms 23916 KB Output is correct
2 Correct 812 ms 23968 KB Output is correct
3 Correct 724 ms 23948 KB Output is correct
4 Correct 821 ms 23920 KB Output is correct
5 Correct 747 ms 23900 KB Output is correct
6 Correct 729 ms 24040 KB Output is correct
7 Correct 686 ms 23972 KB Output is correct
8 Correct 752 ms 23944 KB Output is correct
9 Correct 705 ms 23908 KB Output is correct
10 Correct 746 ms 24000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 808 ms 23924 KB Output is correct
2 Correct 817 ms 23896 KB Output is correct
3 Correct 800 ms 24056 KB Output is correct
4 Correct 773 ms 24140 KB Output is correct
5 Correct 851 ms 23936 KB Output is correct
6 Correct 839 ms 23916 KB Output is correct
7 Correct 801 ms 23932 KB Output is correct
8 Correct 764 ms 24048 KB Output is correct
9 Correct 814 ms 23960 KB Output is correct
10 Correct 792 ms 24064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 668 ms 21584 KB Output is correct
2 Correct 685 ms 21584 KB Output is correct
3 Correct 622 ms 21640 KB Output is correct
4 Correct 665 ms 21600 KB Output is correct
5 Correct 646 ms 21840 KB Output is correct
6 Correct 757 ms 21600 KB Output is correct
7 Correct 672 ms 21588 KB Output is correct
8 Correct 724 ms 21572 KB Output is correct
9 Correct 668 ms 21612 KB Output is correct
10 Correct 659 ms 21624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 668 ms 21584 KB Output is correct
2 Correct 685 ms 21584 KB Output is correct
3 Correct 622 ms 21640 KB Output is correct
4 Correct 665 ms 21600 KB Output is correct
5 Correct 646 ms 21840 KB Output is correct
6 Correct 757 ms 21600 KB Output is correct
7 Correct 672 ms 21588 KB Output is correct
8 Correct 724 ms 21572 KB Output is correct
9 Correct 668 ms 21612 KB Output is correct
10 Correct 659 ms 21624 KB Output is correct
11 Correct 667 ms 21604 KB Output is correct
12 Correct 672 ms 21612 KB Output is correct
13 Correct 635 ms 21604 KB Output is correct
14 Correct 654 ms 21596 KB Output is correct
15 Correct 672 ms 21636 KB Output is correct
16 Correct 651 ms 21644 KB Output is correct
17 Correct 661 ms 21860 KB Output is correct
18 Correct 655 ms 21616 KB Output is correct
19 Correct 756 ms 21748 KB Output is correct
20 Correct 667 ms 21744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 668 ms 21584 KB Output is correct
2 Correct 685 ms 21584 KB Output is correct
3 Correct 622 ms 21640 KB Output is correct
4 Correct 665 ms 21600 KB Output is correct
5 Correct 646 ms 21840 KB Output is correct
6 Correct 757 ms 21600 KB Output is correct
7 Correct 672 ms 21588 KB Output is correct
8 Correct 724 ms 21572 KB Output is correct
9 Correct 668 ms 21612 KB Output is correct
10 Correct 659 ms 21624 KB Output is correct
11 Correct 667 ms 21604 KB Output is correct
12 Correct 672 ms 21612 KB Output is correct
13 Correct 635 ms 21604 KB Output is correct
14 Correct 654 ms 21596 KB Output is correct
15 Correct 672 ms 21636 KB Output is correct
16 Correct 651 ms 21644 KB Output is correct
17 Correct 661 ms 21860 KB Output is correct
18 Correct 655 ms 21616 KB Output is correct
19 Correct 756 ms 21748 KB Output is correct
20 Correct 667 ms 21744 KB Output is correct
21 Correct 683 ms 21612 KB Output is correct
22 Correct 675 ms 21616 KB Output is correct
23 Correct 689 ms 21620 KB Output is correct
24 Correct 659 ms 21632 KB Output is correct
25 Correct 685 ms 21596 KB Output is correct
26 Correct 724 ms 21592 KB Output is correct
27 Correct 742 ms 21644 KB Output is correct
28 Correct 694 ms 21616 KB Output is correct
29 Correct 664 ms 21608 KB Output is correct
30 Correct 640 ms 21624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 677 ms 23868 KB Output is correct
2 Correct 694 ms 23932 KB Output is correct
3 Correct 688 ms 23976 KB Output is correct
4 Correct 706 ms 24188 KB Output is correct
5 Correct 664 ms 23948 KB Output is correct
6 Correct 725 ms 23920 KB Output is correct
7 Correct 690 ms 23892 KB Output is correct
8 Correct 695 ms 23928 KB Output is correct
9 Correct 706 ms 24052 KB Output is correct
10 Correct 706 ms 23928 KB Output is correct
11 Correct 692 ms 23916 KB Output is correct
12 Correct 812 ms 23968 KB Output is correct
13 Correct 724 ms 23948 KB Output is correct
14 Correct 821 ms 23920 KB Output is correct
15 Correct 747 ms 23900 KB Output is correct
16 Correct 729 ms 24040 KB Output is correct
17 Correct 686 ms 23972 KB Output is correct
18 Correct 752 ms 23944 KB Output is correct
19 Correct 705 ms 23908 KB Output is correct
20 Correct 746 ms 24000 KB Output is correct
21 Correct 808 ms 23924 KB Output is correct
22 Correct 817 ms 23896 KB Output is correct
23 Correct 800 ms 24056 KB Output is correct
24 Correct 773 ms 24140 KB Output is correct
25 Correct 851 ms 23936 KB Output is correct
26 Correct 839 ms 23916 KB Output is correct
27 Correct 801 ms 23932 KB Output is correct
28 Correct 764 ms 24048 KB Output is correct
29 Correct 814 ms 23960 KB Output is correct
30 Correct 792 ms 24064 KB Output is correct
31 Correct 668 ms 21584 KB Output is correct
32 Correct 685 ms 21584 KB Output is correct
33 Correct 622 ms 21640 KB Output is correct
34 Correct 665 ms 21600 KB Output is correct
35 Correct 646 ms 21840 KB Output is correct
36 Correct 757 ms 21600 KB Output is correct
37 Correct 672 ms 21588 KB Output is correct
38 Correct 724 ms 21572 KB Output is correct
39 Correct 668 ms 21612 KB Output is correct
40 Correct 659 ms 21624 KB Output is correct
41 Correct 667 ms 21604 KB Output is correct
42 Correct 672 ms 21612 KB Output is correct
43 Correct 635 ms 21604 KB Output is correct
44 Correct 654 ms 21596 KB Output is correct
45 Correct 672 ms 21636 KB Output is correct
46 Correct 651 ms 21644 KB Output is correct
47 Correct 661 ms 21860 KB Output is correct
48 Correct 655 ms 21616 KB Output is correct
49 Correct 756 ms 21748 KB Output is correct
50 Correct 667 ms 21744 KB Output is correct
51 Correct 683 ms 21612 KB Output is correct
52 Correct 675 ms 21616 KB Output is correct
53 Correct 689 ms 21620 KB Output is correct
54 Correct 659 ms 21632 KB Output is correct
55 Correct 685 ms 21596 KB Output is correct
56 Correct 724 ms 21592 KB Output is correct
57 Correct 742 ms 21644 KB Output is correct
58 Correct 694 ms 21616 KB Output is correct
59 Correct 664 ms 21608 KB Output is correct
60 Correct 640 ms 21624 KB Output is correct
61 Correct 810 ms 23892 KB Output is correct
62 Correct 762 ms 23956 KB Output is correct
63 Correct 806 ms 24080 KB Output is correct
64 Correct 815 ms 23924 KB Output is correct
65 Correct 854 ms 23976 KB Output is correct
66 Correct 810 ms 23908 KB Output is correct
67 Correct 823 ms 23884 KB Output is correct
68 Correct 778 ms 23988 KB Output is correct
69 Correct 800 ms 24032 KB Output is correct
70 Correct 798 ms 23864 KB Output is correct