#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
#define f first
#define s second
#define LOGN 21
const ll MOD = 1e9 + 7;
const ll MAXN = 2100;
vector<pair<int,int>> v;
vector<vector<int>> dp;
int main() {
fast;
int n, k;
cin >> n >> k;
v = vector<pair<int,int>>(n);
for (int i = 0; i < n; i++)
cin >> v[i].s >> v[i].f;
sort(v.begin(), v.end());
dp = vector<vector<int>>(n+1, vector<int>());
dp[0].push_back(0);
for (auto u : v) {
for (int i = n; i >= 0; i--) {
if (i+1 > u.f)
continue;
for (auto Q : dp[i]) {
dp[i + 1].push_back(Q + u.s);
}
}
}
for (int i = n; k && i >= 0; i--) {
sort(dp[i].begin(), dp[i].end(), greater<int>());
while (k && dp[i].size()) {
cout << i << " " << dp[i].back() << "\n";
k--;
dp[i].pop_back();
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
513 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
513 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
534 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
2788 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
542 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
513 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |