답안 #278004

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
278004 2020-08-21T08:31:03 Z 임성재(#5118) Shopping Plans (CCO20_day2problem3) C++17
5 / 25
4000 ms 71112 KB
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;

int n, m, k;
vector<ll> g[200010];
bool flag;

int main() {
	fast;

	cin >> n >> m >> k;

	for(int i=1; i<=n; i++) {
		int a, c;
		cin >> a >> c;

		g[a].eb(c);
	}

	vector<ll> v, t;
	v.eb(0);

	for(int i=1; i<=m; i++) {
		t.clear();

		if(g[i].empty()) v.clear();

		for(auto j : g[i]) {
			for(auto l : v) {
				t.eb(l + j);
			}
		}

		sort(all(t));

		if(t.size() > k) t.erase(t.begin() + k, t.end());

		v = t;
	}

	for(int i=0; i<k; i++) {
		if(i < v.size()) cout << v[i] << "\n";
		else cout << "-1\n";
	}
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:50:15: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |   if(t.size() > k) t.erase(t.begin() + k, t.end());
      |      ~~~~~~~~~^~~
Main.cpp:56:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   if(i < v.size()) cout << v[i] << "\n";
      |      ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 309 ms 5512 KB Output is correct
2 Correct 501 ms 9448 KB Output is correct
3 Correct 440 ms 5876 KB Output is correct
4 Correct 601 ms 9456 KB Output is correct
5 Correct 302 ms 5632 KB Output is correct
6 Correct 366 ms 5628 KB Output is correct
7 Correct 780 ms 71112 KB Output is correct
8 Correct 716 ms 70936 KB Output is correct
9 Correct 6 ms 5248 KB Output is correct
10 Correct 498 ms 9448 KB Output is correct
11 Correct 14 ms 6392 KB Output is correct
12 Correct 6 ms 5248 KB Output is correct
13 Correct 24 ms 5484 KB Output is correct
14 Correct 430 ms 5884 KB Output is correct
15 Correct 7 ms 5824 KB Output is correct
16 Correct 26 ms 6332 KB Output is correct
17 Correct 610 ms 9448 KB Output is correct
18 Correct 5 ms 5248 KB Output is correct
19 Correct 20 ms 5376 KB Output is correct
20 Correct 302 ms 5632 KB Output is correct
21 Correct 4 ms 5120 KB Output is correct
22 Correct 20 ms 7348 KB Output is correct
23 Correct 1047 ms 71068 KB Output is correct
24 Correct 626 ms 38092 KB Output is correct
25 Correct 620 ms 38092 KB Output is correct
26 Correct 270 ms 5876 KB Output is correct
27 Correct 351 ms 9328 KB Output is correct
28 Correct 386 ms 70968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4067 ms 14936 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 309 ms 5512 KB Output is correct
2 Correct 501 ms 9448 KB Output is correct
3 Correct 440 ms 5876 KB Output is correct
4 Correct 601 ms 9456 KB Output is correct
5 Correct 302 ms 5632 KB Output is correct
6 Correct 366 ms 5628 KB Output is correct
7 Correct 780 ms 71112 KB Output is correct
8 Correct 716 ms 70936 KB Output is correct
9 Correct 6 ms 5248 KB Output is correct
10 Correct 498 ms 9448 KB Output is correct
11 Correct 14 ms 6392 KB Output is correct
12 Correct 6 ms 5248 KB Output is correct
13 Correct 24 ms 5484 KB Output is correct
14 Correct 430 ms 5884 KB Output is correct
15 Correct 7 ms 5824 KB Output is correct
16 Correct 26 ms 6332 KB Output is correct
17 Correct 610 ms 9448 KB Output is correct
18 Correct 5 ms 5248 KB Output is correct
19 Correct 20 ms 5376 KB Output is correct
20 Correct 302 ms 5632 KB Output is correct
21 Correct 4 ms 5120 KB Output is correct
22 Correct 20 ms 7348 KB Output is correct
23 Correct 1047 ms 71068 KB Output is correct
24 Correct 626 ms 38092 KB Output is correct
25 Correct 620 ms 38092 KB Output is correct
26 Correct 270 ms 5876 KB Output is correct
27 Correct 351 ms 9328 KB Output is correct
28 Correct 386 ms 70968 KB Output is correct
29 Execution timed out 4067 ms 14936 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 5632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 309 ms 5512 KB Output is correct
2 Correct 501 ms 9448 KB Output is correct
3 Correct 440 ms 5876 KB Output is correct
4 Correct 601 ms 9456 KB Output is correct
5 Correct 302 ms 5632 KB Output is correct
6 Correct 366 ms 5628 KB Output is correct
7 Correct 780 ms 71112 KB Output is correct
8 Correct 716 ms 70936 KB Output is correct
9 Correct 6 ms 5248 KB Output is correct
10 Correct 498 ms 9448 KB Output is correct
11 Correct 14 ms 6392 KB Output is correct
12 Correct 6 ms 5248 KB Output is correct
13 Correct 24 ms 5484 KB Output is correct
14 Correct 430 ms 5884 KB Output is correct
15 Correct 7 ms 5824 KB Output is correct
16 Correct 26 ms 6332 KB Output is correct
17 Correct 610 ms 9448 KB Output is correct
18 Correct 5 ms 5248 KB Output is correct
19 Correct 20 ms 5376 KB Output is correct
20 Correct 302 ms 5632 KB Output is correct
21 Correct 4 ms 5120 KB Output is correct
22 Correct 20 ms 7348 KB Output is correct
23 Correct 1047 ms 71068 KB Output is correct
24 Correct 626 ms 38092 KB Output is correct
25 Correct 620 ms 38092 KB Output is correct
26 Correct 270 ms 5876 KB Output is correct
27 Correct 351 ms 9328 KB Output is correct
28 Correct 386 ms 70968 KB Output is correct
29 Execution timed out 4067 ms 14936 KB Time limit exceeded
30 Halted 0 ms 0 KB -