| Task: | Lisäykset |
| Sender: | Kuha |
| Submission time: | 2025-11-28 21:45:49 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 53 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 20 |
| #2 | ACCEPTED | 33 |
| #3 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #2 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #3 | ACCEPTED | 0.01 s | 1, 3 | details |
| #4 | ACCEPTED | 0.01 s | 1, 3 | details |
| #5 | ACCEPTED | 0.03 s | 1, 3 | details |
| #6 | ACCEPTED | 0.09 s | 2, 3 | details |
| #7 | ACCEPTED | 0.09 s | 3 | details |
| #8 | ACCEPTED | 0.09 s | 3 | details |
| #9 | ACCEPTED | 0.11 s | 3 | details |
| #10 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #11 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#include <bits/stdc++.h>
using namespace std;
int cnt[1111111];
int main () {
int n, m;
cin>>n>>m;
for (int i = 0; i < n; i++) {
int x;
cin>>x;
cnt[x]++;
}
set<int> ne;
for (int i = 0; i <= 1000000; i++) {
if (cnt[i]) ne.insert(i);
}
for (int i = 0; i < m; i++) {
int prev = 0;
int previ = 0;
int k;
vector<int> ops;
cin>>k;
//cout<<"NEW "<<k<<endl;
for (int i : ne) {
//cout<<"i "<<i<<endl;
if (previ + 1 != i) prev = 0;
if (cnt[i] - prev >= k) {
//cout<<"MOVE "<<i<<" "<<(k)<<endl;
cnt[i] -= k;
cnt[i + 1] += k;
ops.push_back(i);
ops.push_back(i + 1);
break;
} else {
//cout<<"MOVE "<<i<<" "<<(cnt[i] - prev)<<endl;
cnt[i + 1] += cnt[i] - prev;
k -= cnt[i] - prev;
int x = cnt[i];
cnt[i] = prev;
prev = x - prev;
ops.push_back(i);
ops.push_back(i + 1);
}
previ = i;
}
for (int i : ops) {
if (cnt[i]) ne.insert(i);
else ne.erase(i);
}
}
for (int i = 0; i < 1111111; i++) {
while (cnt[i]--) cout<<i<<" ";
}
cout<<endl;
}Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 1 1000 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
| correct output |
|---|
| 1000 |
| user output |
|---|
| 1000 |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 1000 1000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... |
| correct output |
|---|
| 511 511 511 511 511 511 511 51... |
| user output |
|---|
| 511 511 511 511 511 511 511 51... |
Test 3
Group: 1, 3
Verdict: ACCEPTED
| input |
|---|
| 1000 1000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... |
| correct output |
|---|
| 495 495 495 495 495 495 495 49... |
| user output |
|---|
| 495 495 495 495 495 495 495 49... |
Test 4
Group: 1, 3
Verdict: ACCEPTED
| input |
|---|
| 1000 1000 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 ... |
| correct output |
|---|
| 562 562 562 562 562 562 562 56... |
| user output |
|---|
| 562 562 562 562 562 562 562 56... |
Test 5
Group: 1, 3
Verdict: ACCEPTED
| input |
|---|
| 1000 1000 0 1 3 4 6 9 9 9 10 11 11 11 11... |
| correct output |
|---|
| 997 997 997 997 997 998 998 99... |
| user output |
|---|
| 997 997 997 997 997 998 998 99... |
Test 6
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 100000 100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... |
| correct output |
|---|
| 50033 50033 50033 50033 50033 ... |
| user output |
|---|
| 50033 50033 50033 50033 50033 ... |
Test 7
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 100000 100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... |
| correct output |
|---|
| 49996 49996 49996 49996 49996 ... |
| user output |
|---|
| 49996 49996 49996 49996 49996 ... |
Test 8
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 100000 100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... |
| correct output |
|---|
| 50057 50057 50057 50057 50057 ... |
| user output |
|---|
| 50057 50057 50057 50057 50057 ... |
Test 9
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 100000 100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... |
| correct output |
|---|
| 50536 50536 50536 50536 50536 ... |
| user output |
|---|
| 50536 50536 50536 50536 50536 ... |
Test 10
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 100000 0 4 7 29 33 44 52 75 77 79 82 ... |
| correct output |
|---|
| 100000 100001 100003 100023 10... |
| user output |
|---|
| (empty) |
Test 11
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 100000 1 12 14 16 49 59 59 63 68 73 8... |
| correct output |
|---|
| 100001 100010 100012 100014 10... |
| user output |
|---|
| (empty) |
