답안 #991309

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
991309 2024-06-01T21:27:26 Z xnqs Feast (NOI19_feast) C++17
71 / 100
116 ms 14076 KB
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <cstring>

int x, k;
int arr[300005];
std::pair<int64_t,int> dp[300005][2];

std::pair<int64_t,int> sol(int64_t lambda) {
	dp[0][0] = {0,0};
	dp[0][1] = {arr[0]-lambda,1};
	for (int i = 1; i < x; i++) {
		dp[i][0] = std::max(dp[i-1][0],dp[i-1][1]);
		dp[i][1] = std::max(std::pair<int64_t,int>(dp[i-1][0].first+arr[i]-lambda,dp[i-1][0].second+1),std::pair<int64_t,int>(dp[i-1][1].first+arr[i],dp[i-1][1].second));
	}
	return std::max(dp[x-1][0],dp[x-1][1]);
}

int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);

	std::cin >> x >> k;
	for (int i = 0; i < x; i++) {
		std::cin >> arr[i];
	}

	const auto bs = [&]() {
		int64_t l = 0, r = 1000000000000000000;
		int64_t ret = 69420;
		while (l<=r) {
			int64_t m = (l+r)>>1;
			if (sol(m).second>=k) {
				ret = m;
				l = m+1;
			}
			else {
				r = m-1;
			}
		}
		return ret;
	};

	int64_t ret = bs();
	std::cout << sol(ret).first + ret*sol(ret).second << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 10844 KB Output is correct
2 Correct 52 ms 13624 KB Output is correct
3 Correct 50 ms 13760 KB Output is correct
4 Correct 51 ms 13652 KB Output is correct
5 Correct 50 ms 13656 KB Output is correct
6 Correct 49 ms 13632 KB Output is correct
7 Correct 48 ms 13652 KB Output is correct
8 Correct 51 ms 13636 KB Output is correct
9 Correct 53 ms 13620 KB Output is correct
10 Correct 50 ms 13652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 10840 KB Output is correct
2 Correct 43 ms 10840 KB Output is correct
3 Correct 42 ms 10844 KB Output is correct
4 Correct 42 ms 10840 KB Output is correct
5 Correct 54 ms 13660 KB Output is correct
6 Correct 42 ms 11868 KB Output is correct
7 Correct 42 ms 12124 KB Output is correct
8 Correct 49 ms 13660 KB Output is correct
9 Correct 49 ms 13652 KB Output is correct
10 Correct 42 ms 12124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 10844 KB Output is correct
2 Correct 77 ms 10980 KB Output is correct
3 Correct 79 ms 10844 KB Output is correct
4 Correct 75 ms 10952 KB Output is correct
5 Correct 81 ms 11100 KB Output is correct
6 Correct 77 ms 10840 KB Output is correct
7 Correct 73 ms 10952 KB Output is correct
8 Correct 76 ms 10984 KB Output is correct
9 Correct 77 ms 10836 KB Output is correct
10 Correct 78 ms 10832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2532 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 10844 KB Output is correct
2 Correct 52 ms 13624 KB Output is correct
3 Correct 50 ms 13760 KB Output is correct
4 Correct 51 ms 13652 KB Output is correct
5 Correct 50 ms 13656 KB Output is correct
6 Correct 49 ms 13632 KB Output is correct
7 Correct 48 ms 13652 KB Output is correct
8 Correct 51 ms 13636 KB Output is correct
9 Correct 53 ms 13620 KB Output is correct
10 Correct 50 ms 13652 KB Output is correct
11 Correct 41 ms 10840 KB Output is correct
12 Correct 43 ms 10840 KB Output is correct
13 Correct 42 ms 10844 KB Output is correct
14 Correct 42 ms 10840 KB Output is correct
15 Correct 54 ms 13660 KB Output is correct
16 Correct 42 ms 11868 KB Output is correct
17 Correct 42 ms 12124 KB Output is correct
18 Correct 49 ms 13660 KB Output is correct
19 Correct 49 ms 13652 KB Output is correct
20 Correct 42 ms 12124 KB Output is correct
21 Correct 76 ms 10844 KB Output is correct
22 Correct 77 ms 10980 KB Output is correct
23 Correct 79 ms 10844 KB Output is correct
24 Correct 75 ms 10952 KB Output is correct
25 Correct 81 ms 11100 KB Output is correct
26 Correct 77 ms 10840 KB Output is correct
27 Correct 73 ms 10952 KB Output is correct
28 Correct 76 ms 10984 KB Output is correct
29 Correct 77 ms 10836 KB Output is correct
30 Correct 78 ms 10832 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 0 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 0 ms 2396 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 0 ms 2396 KB Output is correct
40 Correct 0 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2652 KB Output is correct
44 Correct 0 ms 2396 KB Output is correct
45 Correct 0 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 0 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 1 ms 2532 KB Output is correct
53 Correct 1 ms 2396 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 1 ms 2396 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 1 ms 2396 KB Output is correct
59 Correct 1 ms 2396 KB Output is correct
60 Correct 1 ms 2396 KB Output is correct
61 Correct 112 ms 13888 KB Output is correct
62 Incorrect 116 ms 14076 KB Output isn't correct
63 Halted 0 ms 0 KB -