답안 #528377

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
528377 2022-02-20T08:14:35 Z CSQ31 Akcija (COCI21_akcija) C++17
90 / 110
5000 ms 31196 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define sz(a) (int)(a.size())
int n,k;
vector<ll>s[2001];
vector<ll>comb(vector<ll>a,vector<ll>b,ll x){
	int p = 0,q = 0;
	vector<ll>c;
	while(p != sz(a) || q != sz(b)){
		if(q!=sz(b) && (p==sz(a) || a[p] > b[q]+x)){
			c.push_back(b[q]+x);
			q++;
		}else{
			c.push_back(a[p]);
			p++;
		}
	}
	while(sz(c) > k)c.pop_back();
	return c;
}
int main()
{
	cin>>n>>k;
	vector<array<ll,2>>v(n);
	s[0] = {0};
	for(int i=0;i<n;i++)cin>>v[i][1]>>v[i][0];
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++){
		for(int j=n;j;j--){
			if(!sz(s[j-1]))continue;
			if(v[i][0] >= j)s[j] = comb(s[j],s[j-1],v[i][1]);
		}
	}
	int cnt = 0;
	for(int j=n;j>=1;j--){
		if(cnt==k)break;
		for(ll x:s[j]){
			cout<<j<<" "<<x<<'\n';
			cnt++;
			if(cnt==k)break;
		}
	}
	while(cnt < k){
		cnt++;
		cout<<0<<" "<<0<<'\n';
	}

}
# 결과 실행 시간 메모리 Grader output
1 Correct 198 ms 400 KB Output is correct
2 Correct 210 ms 384 KB Output is correct
3 Correct 185 ms 580 KB Output is correct
4 Correct 179 ms 380 KB Output is correct
5 Correct 214 ms 492 KB Output is correct
6 Correct 4 ms 332 KB Output is correct
7 Correct 5 ms 332 KB Output is correct
8 Correct 5 ms 332 KB Output is correct
9 Correct 9 ms 360 KB Output is correct
10 Correct 50 ms 372 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 198 ms 400 KB Output is correct
2 Correct 210 ms 384 KB Output is correct
3 Correct 185 ms 580 KB Output is correct
4 Correct 179 ms 380 KB Output is correct
5 Correct 214 ms 492 KB Output is correct
6 Correct 4 ms 332 KB Output is correct
7 Correct 5 ms 332 KB Output is correct
8 Correct 5 ms 332 KB Output is correct
9 Correct 9 ms 360 KB Output is correct
10 Correct 50 ms 372 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 192 ms 380 KB Output is correct
15 Correct 203 ms 404 KB Output is correct
16 Correct 177 ms 404 KB Output is correct
17 Correct 180 ms 332 KB Output is correct
18 Correct 203 ms 416 KB Output is correct
19 Correct 4 ms 332 KB Output is correct
20 Correct 6 ms 332 KB Output is correct
21 Correct 5 ms 392 KB Output is correct
22 Correct 9 ms 332 KB Output is correct
23 Correct 50 ms 392 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 257 ms 388 KB Output is correct
2 Correct 277 ms 660 KB Output is correct
3 Correct 221 ms 452 KB Output is correct
4 Correct 224 ms 404 KB Output is correct
5 Correct 275 ms 708 KB Output is correct
6 Correct 4 ms 356 KB Output is correct
7 Correct 7 ms 356 KB Output is correct
8 Correct 5 ms 332 KB Output is correct
9 Correct 10 ms 396 KB Output is correct
10 Correct 62 ms 400 KB Output is correct
11 Correct 0 ms 336 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 844 KB Output is correct
2 Correct 2 ms 844 KB Output is correct
3 Correct 2 ms 844 KB Output is correct
4 Correct 3 ms 716 KB Output is correct
5 Correct 3 ms 844 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 580 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 2 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 460 KB Output is correct
2 Correct 4 ms 464 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 4 ms 464 KB Output is correct
5 Correct 5 ms 516 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 412 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 198 ms 400 KB Output is correct
2 Correct 210 ms 384 KB Output is correct
3 Correct 185 ms 580 KB Output is correct
4 Correct 179 ms 380 KB Output is correct
5 Correct 214 ms 492 KB Output is correct
6 Correct 4 ms 332 KB Output is correct
7 Correct 5 ms 332 KB Output is correct
8 Correct 5 ms 332 KB Output is correct
9 Correct 9 ms 360 KB Output is correct
10 Correct 50 ms 372 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 192 ms 380 KB Output is correct
15 Correct 203 ms 404 KB Output is correct
16 Correct 177 ms 404 KB Output is correct
17 Correct 180 ms 332 KB Output is correct
18 Correct 203 ms 416 KB Output is correct
19 Correct 4 ms 332 KB Output is correct
20 Correct 6 ms 332 KB Output is correct
21 Correct 5 ms 392 KB Output is correct
22 Correct 9 ms 332 KB Output is correct
23 Correct 50 ms 392 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 257 ms 388 KB Output is correct
28 Correct 277 ms 660 KB Output is correct
29 Correct 221 ms 452 KB Output is correct
30 Correct 224 ms 404 KB Output is correct
31 Correct 275 ms 708 KB Output is correct
32 Correct 4 ms 356 KB Output is correct
33 Correct 7 ms 356 KB Output is correct
34 Correct 5 ms 332 KB Output is correct
35 Correct 10 ms 396 KB Output is correct
36 Correct 62 ms 400 KB Output is correct
37 Correct 0 ms 336 KB Output is correct
38 Correct 0 ms 332 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 3 ms 844 KB Output is correct
41 Correct 2 ms 844 KB Output is correct
42 Correct 2 ms 844 KB Output is correct
43 Correct 3 ms 716 KB Output is correct
44 Correct 3 ms 844 KB Output is correct
45 Correct 0 ms 332 KB Output is correct
46 Correct 1 ms 580 KB Output is correct
47 Correct 1 ms 464 KB Output is correct
48 Correct 1 ms 460 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 0 ms 332 KB Output is correct
51 Correct 0 ms 332 KB Output is correct
52 Correct 2 ms 724 KB Output is correct
53 Correct 5 ms 460 KB Output is correct
54 Correct 4 ms 464 KB Output is correct
55 Correct 4 ms 468 KB Output is correct
56 Correct 4 ms 464 KB Output is correct
57 Correct 5 ms 516 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 1 ms 332 KB Output is correct
62 Correct 2 ms 412 KB Output is correct
63 Correct 0 ms 332 KB Output is correct
64 Correct 1 ms 332 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Execution timed out 5047 ms 31196 KB Time limit exceeded
67 Halted 0 ms 0 KB -