Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ametus.h>
- MI cin;
- const int $n = 3005;
- const int $m = $n * ($n + 1) / 2;
- int n, m, v[$n], w[$m];
- std::priority_queue<int, std::vector<int>, std::greater<int>> q;
- int main() {
- cin > n; m = n * (n + 1) / 2;
- E(i, m) cin > w[i];
- std::sort(w + 1, w + m + 1);
- int j = 1;
- E(i, n) {
- while (!q.empty() && q.top() == w[j]) q.pop(), ++j;
- assert(j <= m);
- v[i] = w[j]; int s = 0;
- for (int k = i; k; --k) q.push(s += v[k]);
- cout < v[i] < " \n"[i == n];
- }
- }
Add Comment
Please, Sign In to add comment