답안 #962655

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
962655 2024-04-14T06:23:22 Z biximo Feast (NOI19_feast) C++17
100 / 100
908 ms 23540 KB
#include <bits/stdc++.h>
#define N 300005
using namespace std;
typedef pair<long double, int> pi;
pi DP[N][2];
int n, k, seq[N];
int doDP(long double pen) {
	for(auto&i: DP) for(auto&j: i) j = make_pair(-9e18,0);
	DP[0][0] = {0,0};
	for(int i = 1; i <= n+1; i ++) {
		DP[i][0] = max(DP[i-1][0], DP[i-1][1]);
		DP[i][1] = max(DP[i-1][1], make_pair(DP[i-1][0].first-pen, DP[i-1][0].second+1));
		DP[i][1].first += seq[i];
	}
	return DP[n+1][0].second;
}
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> k;
    int pc = 0;
    for(int i = 1; i <= n; i ++) {
    	cin >> seq[i];
    	if(seq[i] > 0 && seq[i-1] <= 0) pc ++;
    }
    k = min(k, pc);
    long double l=0,h=1e13;
    for(int i = 0; i < 100; i ++) {
    	long double m = (l+h)/2;
    	int res = doDP(m);
    	if(res > k) {
    		l = m;
    	} else {
    		h = m;
    	}
    }
    cout << (long long)round(DP[n+1][0].first + k*l);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 635 ms 20396 KB Output is correct
2 Correct 638 ms 23244 KB Output is correct
3 Correct 646 ms 23120 KB Output is correct
4 Correct 632 ms 23252 KB Output is correct
5 Correct 665 ms 23244 KB Output is correct
6 Correct 632 ms 23200 KB Output is correct
7 Correct 641 ms 23188 KB Output is correct
8 Correct 622 ms 23248 KB Output is correct
9 Correct 676 ms 23028 KB Output is correct
10 Correct 630 ms 23228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 620 ms 20396 KB Output is correct
2 Correct 637 ms 21540 KB Output is correct
3 Correct 617 ms 21508 KB Output is correct
4 Correct 628 ms 21340 KB Output is correct
5 Correct 629 ms 23196 KB Output is correct
6 Correct 634 ms 21512 KB Output is correct
7 Correct 644 ms 21540 KB Output is correct
8 Correct 623 ms 23120 KB Output is correct
9 Correct 615 ms 23128 KB Output is correct
10 Correct 623 ms 21524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 676 ms 20396 KB Output is correct
2 Correct 675 ms 23388 KB Output is correct
3 Correct 717 ms 23380 KB Output is correct
4 Correct 693 ms 23384 KB Output is correct
5 Correct 697 ms 23412 KB Output is correct
6 Correct 679 ms 23428 KB Output is correct
7 Correct 689 ms 23440 KB Output is correct
8 Correct 681 ms 23540 KB Output is correct
9 Correct 695 ms 23448 KB Output is correct
10 Correct 684 ms 23440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 262 ms 20216 KB Output is correct
2 Correct 255 ms 20056 KB Output is correct
3 Correct 259 ms 20308 KB Output is correct
4 Correct 253 ms 20220 KB Output is correct
5 Correct 258 ms 20216 KB Output is correct
6 Correct 257 ms 20304 KB Output is correct
7 Correct 256 ms 20216 KB Output is correct
8 Correct 260 ms 20216 KB Output is correct
9 Correct 259 ms 20212 KB Output is correct
10 Correct 254 ms 20216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 262 ms 20216 KB Output is correct
2 Correct 255 ms 20056 KB Output is correct
3 Correct 259 ms 20308 KB Output is correct
4 Correct 253 ms 20220 KB Output is correct
5 Correct 258 ms 20216 KB Output is correct
6 Correct 257 ms 20304 KB Output is correct
7 Correct 256 ms 20216 KB Output is correct
8 Correct 260 ms 20216 KB Output is correct
9 Correct 259 ms 20212 KB Output is correct
10 Correct 254 ms 20216 KB Output is correct
11 Correct 265 ms 20308 KB Output is correct
12 Correct 254 ms 20056 KB Output is correct
13 Correct 258 ms 20308 KB Output is correct
14 Correct 254 ms 20224 KB Output is correct
15 Correct 253 ms 20216 KB Output is correct
16 Correct 262 ms 20056 KB Output is correct
17 Correct 258 ms 20056 KB Output is correct
18 Correct 258 ms 20220 KB Output is correct
19 Correct 267 ms 20224 KB Output is correct
20 Correct 258 ms 20220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 262 ms 20216 KB Output is correct
2 Correct 255 ms 20056 KB Output is correct
3 Correct 259 ms 20308 KB Output is correct
4 Correct 253 ms 20220 KB Output is correct
5 Correct 258 ms 20216 KB Output is correct
6 Correct 257 ms 20304 KB Output is correct
7 Correct 256 ms 20216 KB Output is correct
8 Correct 260 ms 20216 KB Output is correct
9 Correct 259 ms 20212 KB Output is correct
10 Correct 254 ms 20216 KB Output is correct
11 Correct 265 ms 20308 KB Output is correct
12 Correct 254 ms 20056 KB Output is correct
13 Correct 258 ms 20308 KB Output is correct
14 Correct 254 ms 20224 KB Output is correct
15 Correct 253 ms 20216 KB Output is correct
16 Correct 262 ms 20056 KB Output is correct
17 Correct 258 ms 20056 KB Output is correct
18 Correct 258 ms 20220 KB Output is correct
19 Correct 267 ms 20224 KB Output is correct
20 Correct 258 ms 20220 KB Output is correct
21 Correct 265 ms 20312 KB Output is correct
22 Correct 259 ms 20056 KB Output is correct
23 Correct 278 ms 20308 KB Output is correct
24 Correct 256 ms 20056 KB Output is correct
25 Correct 272 ms 20056 KB Output is correct
26 Correct 271 ms 20244 KB Output is correct
27 Correct 262 ms 20060 KB Output is correct
28 Correct 262 ms 20248 KB Output is correct
29 Correct 261 ms 20252 KB Output is correct
30 Correct 262 ms 20060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 635 ms 20396 KB Output is correct
2 Correct 638 ms 23244 KB Output is correct
3 Correct 646 ms 23120 KB Output is correct
4 Correct 632 ms 23252 KB Output is correct
5 Correct 665 ms 23244 KB Output is correct
6 Correct 632 ms 23200 KB Output is correct
7 Correct 641 ms 23188 KB Output is correct
8 Correct 622 ms 23248 KB Output is correct
9 Correct 676 ms 23028 KB Output is correct
10 Correct 630 ms 23228 KB Output is correct
11 Correct 620 ms 20396 KB Output is correct
12 Correct 637 ms 21540 KB Output is correct
13 Correct 617 ms 21508 KB Output is correct
14 Correct 628 ms 21340 KB Output is correct
15 Correct 629 ms 23196 KB Output is correct
16 Correct 634 ms 21512 KB Output is correct
17 Correct 644 ms 21540 KB Output is correct
18 Correct 623 ms 23120 KB Output is correct
19 Correct 615 ms 23128 KB Output is correct
20 Correct 623 ms 21524 KB Output is correct
21 Correct 676 ms 20396 KB Output is correct
22 Correct 675 ms 23388 KB Output is correct
23 Correct 717 ms 23380 KB Output is correct
24 Correct 693 ms 23384 KB Output is correct
25 Correct 697 ms 23412 KB Output is correct
26 Correct 679 ms 23428 KB Output is correct
27 Correct 689 ms 23440 KB Output is correct
28 Correct 681 ms 23540 KB Output is correct
29 Correct 695 ms 23448 KB Output is correct
30 Correct 684 ms 23440 KB Output is correct
31 Correct 262 ms 20216 KB Output is correct
32 Correct 255 ms 20056 KB Output is correct
33 Correct 259 ms 20308 KB Output is correct
34 Correct 253 ms 20220 KB Output is correct
35 Correct 258 ms 20216 KB Output is correct
36 Correct 257 ms 20304 KB Output is correct
37 Correct 256 ms 20216 KB Output is correct
38 Correct 260 ms 20216 KB Output is correct
39 Correct 259 ms 20212 KB Output is correct
40 Correct 254 ms 20216 KB Output is correct
41 Correct 265 ms 20308 KB Output is correct
42 Correct 254 ms 20056 KB Output is correct
43 Correct 258 ms 20308 KB Output is correct
44 Correct 254 ms 20224 KB Output is correct
45 Correct 253 ms 20216 KB Output is correct
46 Correct 262 ms 20056 KB Output is correct
47 Correct 258 ms 20056 KB Output is correct
48 Correct 258 ms 20220 KB Output is correct
49 Correct 267 ms 20224 KB Output is correct
50 Correct 258 ms 20220 KB Output is correct
51 Correct 265 ms 20312 KB Output is correct
52 Correct 259 ms 20056 KB Output is correct
53 Correct 278 ms 20308 KB Output is correct
54 Correct 256 ms 20056 KB Output is correct
55 Correct 272 ms 20056 KB Output is correct
56 Correct 271 ms 20244 KB Output is correct
57 Correct 262 ms 20060 KB Output is correct
58 Correct 262 ms 20248 KB Output is correct
59 Correct 261 ms 20252 KB Output is correct
60 Correct 262 ms 20060 KB Output is correct
61 Correct 836 ms 23380 KB Output is correct
62 Correct 844 ms 23452 KB Output is correct
63 Correct 733 ms 23368 KB Output is correct
64 Correct 840 ms 23428 KB Output is correct
65 Correct 908 ms 23424 KB Output is correct
66 Correct 836 ms 23420 KB Output is correct
67 Correct 849 ms 23376 KB Output is correct
68 Correct 707 ms 23428 KB Output is correct
69 Correct 702 ms 23384 KB Output is correct
70 Correct 682 ms 23356 KB Output is correct