#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], v;
priority_queue<ll> pQ;
int main() {
fast;
cin >> n >> m >> k;
for(int i=1; i<=n; i++) {
int a, c;
cin >> a >> c;
g[a].eb(c);
}
pQ.em(0);
for(int i=1; i<=m; i++) {
v.clear();
sort(all(g[i]));
while(pQ.size()) {
v.eb(pQ.top());
pQ.pop();
}
if(g[i].empty()) v.clear();
for(auto j : v) {
for(auto l : g[i]) {
if(pQ.size() == k && pQ.top() <= j + l) break;
else pQ.em(j + l);
if(pQ.size() > k) pQ.pop();
}
}
}
v.clear();
while(pQ.size()) {
v.eb(pQ.top());
pQ.pop();
}
reverse(all(v));
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:18: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
50 | if(pQ.size() == k && pQ.top() <= j + l) break;
| ~~~~~~~~~~^~~~
Main.cpp:53:18: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
53 | if(pQ.size() > k) pQ.pop();
| ~~~~~~~~~~^~~
Main.cpp:67:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | if(i < v.size()) cout << v[i] << "\n";
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1212 ms |
5312 KB |
Output is correct |
2 |
Correct |
997 ms |
5368 KB |
Output is correct |
3 |
Correct |
1194 ms |
5368 KB |
Output is correct |
4 |
Correct |
490 ms |
5304 KB |
Output is correct |
5 |
Correct |
1235 ms |
5368 KB |
Output is correct |
6 |
Correct |
1248 ms |
5368 KB |
Output is correct |
7 |
Correct |
376 ms |
5248 KB |
Output is correct |
8 |
Correct |
34 ms |
5248 KB |
Output is correct |
9 |
Correct |
5 ms |
5248 KB |
Output is correct |
10 |
Correct |
966 ms |
5368 KB |
Output is correct |
11 |
Correct |
18 ms |
5248 KB |
Output is correct |
12 |
Correct |
8 ms |
5120 KB |
Output is correct |
13 |
Correct |
56 ms |
5240 KB |
Output is correct |
14 |
Correct |
1139 ms |
5368 KB |
Output is correct |
15 |
Correct |
10 ms |
5120 KB |
Output is correct |
16 |
Correct |
39 ms |
5240 KB |
Output is correct |
17 |
Correct |
443 ms |
5368 KB |
Output is correct |
18 |
Correct |
9 ms |
5120 KB |
Output is correct |
19 |
Correct |
55 ms |
5240 KB |
Output is correct |
20 |
Correct |
1276 ms |
5344 KB |
Output is correct |
21 |
Correct |
5 ms |
5248 KB |
Output is correct |
22 |
Correct |
12 ms |
5120 KB |
Output is correct |
23 |
Correct |
71 ms |
5248 KB |
Output is correct |
24 |
Correct |
32 ms |
5248 KB |
Output is correct |
25 |
Correct |
29 ms |
5284 KB |
Output is correct |
26 |
Correct |
1148 ms |
5304 KB |
Output is correct |
27 |
Correct |
416 ms |
5368 KB |
Output is correct |
28 |
Correct |
35 ms |
5248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4035 ms |
8752 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1212 ms |
5312 KB |
Output is correct |
2 |
Correct |
997 ms |
5368 KB |
Output is correct |
3 |
Correct |
1194 ms |
5368 KB |
Output is correct |
4 |
Correct |
490 ms |
5304 KB |
Output is correct |
5 |
Correct |
1235 ms |
5368 KB |
Output is correct |
6 |
Correct |
1248 ms |
5368 KB |
Output is correct |
7 |
Correct |
376 ms |
5248 KB |
Output is correct |
8 |
Correct |
34 ms |
5248 KB |
Output is correct |
9 |
Correct |
5 ms |
5248 KB |
Output is correct |
10 |
Correct |
966 ms |
5368 KB |
Output is correct |
11 |
Correct |
18 ms |
5248 KB |
Output is correct |
12 |
Correct |
8 ms |
5120 KB |
Output is correct |
13 |
Correct |
56 ms |
5240 KB |
Output is correct |
14 |
Correct |
1139 ms |
5368 KB |
Output is correct |
15 |
Correct |
10 ms |
5120 KB |
Output is correct |
16 |
Correct |
39 ms |
5240 KB |
Output is correct |
17 |
Correct |
443 ms |
5368 KB |
Output is correct |
18 |
Correct |
9 ms |
5120 KB |
Output is correct |
19 |
Correct |
55 ms |
5240 KB |
Output is correct |
20 |
Correct |
1276 ms |
5344 KB |
Output is correct |
21 |
Correct |
5 ms |
5248 KB |
Output is correct |
22 |
Correct |
12 ms |
5120 KB |
Output is correct |
23 |
Correct |
71 ms |
5248 KB |
Output is correct |
24 |
Correct |
32 ms |
5248 KB |
Output is correct |
25 |
Correct |
29 ms |
5284 KB |
Output is correct |
26 |
Correct |
1148 ms |
5304 KB |
Output is correct |
27 |
Correct |
416 ms |
5368 KB |
Output is correct |
28 |
Correct |
35 ms |
5248 KB |
Output is correct |
29 |
Execution timed out |
4035 ms |
8752 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
5632 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1212 ms |
5312 KB |
Output is correct |
2 |
Correct |
997 ms |
5368 KB |
Output is correct |
3 |
Correct |
1194 ms |
5368 KB |
Output is correct |
4 |
Correct |
490 ms |
5304 KB |
Output is correct |
5 |
Correct |
1235 ms |
5368 KB |
Output is correct |
6 |
Correct |
1248 ms |
5368 KB |
Output is correct |
7 |
Correct |
376 ms |
5248 KB |
Output is correct |
8 |
Correct |
34 ms |
5248 KB |
Output is correct |
9 |
Correct |
5 ms |
5248 KB |
Output is correct |
10 |
Correct |
966 ms |
5368 KB |
Output is correct |
11 |
Correct |
18 ms |
5248 KB |
Output is correct |
12 |
Correct |
8 ms |
5120 KB |
Output is correct |
13 |
Correct |
56 ms |
5240 KB |
Output is correct |
14 |
Correct |
1139 ms |
5368 KB |
Output is correct |
15 |
Correct |
10 ms |
5120 KB |
Output is correct |
16 |
Correct |
39 ms |
5240 KB |
Output is correct |
17 |
Correct |
443 ms |
5368 KB |
Output is correct |
18 |
Correct |
9 ms |
5120 KB |
Output is correct |
19 |
Correct |
55 ms |
5240 KB |
Output is correct |
20 |
Correct |
1276 ms |
5344 KB |
Output is correct |
21 |
Correct |
5 ms |
5248 KB |
Output is correct |
22 |
Correct |
12 ms |
5120 KB |
Output is correct |
23 |
Correct |
71 ms |
5248 KB |
Output is correct |
24 |
Correct |
32 ms |
5248 KB |
Output is correct |
25 |
Correct |
29 ms |
5284 KB |
Output is correct |
26 |
Correct |
1148 ms |
5304 KB |
Output is correct |
27 |
Correct |
416 ms |
5368 KB |
Output is correct |
28 |
Correct |
35 ms |
5248 KB |
Output is correct |
29 |
Execution timed out |
4035 ms |
8752 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |