QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#705949 | #2912. Who Goes There? | vic233333# | AC ✓ | 1ms | 3872kb | C++20 | 1.4kb | 2024-11-03 04:35:29 | 2024-11-03 04:35:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb push_back
const ld pi = 3.14159265358979323846;
const int mod = 998244353;
const ll INF = 1e18;
template<typename T>
T chmax(T a, T b) {
return a > b ? a : b;
}
template<typename T>
T chmin(T a, T b) {
return a > b ? b : a;
}
const int N = (int) 1e5 + 1, M = N * 2;
void solve() {
int n, m;
cin >> n >> m;
vector<int> a(m);
vector<int> ans(m);
int sum = 0;
for (int i = 0; i < m; i++) {
cin >> a[i];
sum += a[i];
}
if (sum <= n) {
for (int i = 0; i < m; ++i) {
cout << a[i] << endl;
}
return;
}
sum = 0;
bool flag = false;
while (sum <= n) {
for (int i = 0; i < m; i++) {
if (a[i] > 0) {
sum++;
a[i]--;
ans[i]++;
}
if (sum == n) {
flag = true;
break;
}
}
if (flag) break;
}
for (int i = 0; i < m; ++i) {
cout << ans[i] << endl;
}
}
int main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3572kb
input:
20 5 7 5 1 6 12
output:
5 5 1 5 4
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
100 100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 100
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok 100 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
100 100 100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok 100 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
10 15 2 3 4 5 3 2 4 6 2 7 3 6 9 2 3
output:
1 1 1 1 1 1 1 1 1 1 0 0 0 0 0
result:
ok 15 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
85 27 15 12 12 8 14 16 12 12 17 18 9 10 20 6 18 5 6 9 7 19 20 5 19 9 16 7 9
output:
4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
result:
ok 27 lines
Test #6:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
6 1 2
output:
2
result:
ok single line: '2'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3872kb
input:
49 39 5 16 5 13 15 19 2 11 3 2 2 16 8 5 15 2 1 20 9 7 7 12 11 17 3 8 7 17 18 20 13 5 9 10 5 16 6 15 8
output:
2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok 39 lines
Test #8:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
6 2 9 14
output:
3 3
result:
ok 2 lines
Test #9:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
26 21 11 2 1 19 11 13 3 19 18 11 12 7 3 11 9 15 9 3 10 11 11
output:
2 2 1 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok 21 lines
Test #10:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
94 48 15 3 20 19 18 20 2 17 19 6 17 7 19 10 16 6 17 12 2 15 20 7 17 6 2 1 6 13 9 2 19 16 18 16 18 15 17 13 14 4 8 2 8 19 9 16 3 16
output:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1
result:
ok 48 lines
Test #11:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
58 43 17 17 1 8 2 1 17 15 16 13 12 15 12 9 3 6 7 4 8 16 5 17 15 7 1 5 19 18 11 11 5 4 6 1 19 19 17 18 2 16 19 10 18
output:
2 2 1 2 2 1 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok 43 lines
Test #12:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
76 22 6 19 8 8 13 2 11 13 2 18 1 9 13 1 12 12 1 3 6 12 5 9
output:
5 5 4 4 4 2 4 4 2 4 1 4 4 1 4 4 1 3 4 4 4 4
result:
ok 22 lines
Test #13:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
91 44 8 4 13 18 10 13 4 19 4 1 15 17 15 2 17 4 2 5 5 14 15 10 6 10 17 2 11 8 19 4 20 1 20 8 1 7 6 10 3 13 9 10 2 5
output:
3 3 3 3 3 3 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 1 2 2 2 2 2 2 2 2 2
result:
ok 44 lines
Test #14:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
92 31 7 12 14 6 19 20 14 16 12 17 9 13 14 1 16 12 19 10 13 13 1 2 6 1 5 3 1 5 10 13 15
output:
4 4 4 4 4 4 4 4 3 3 3 3 3 1 3 3 3 3 3 3 1 2 3 1 3 3 1 3 3 3 3
result:
ok 31 lines
Test #15:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
80 4 92 86 12 36
output:
23 23 12 22
result:
ok 4 lines
Test #16:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
70 4 45 83 89 23
output:
18 18 17 17
result:
ok 4 lines
Test #17:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
98 5 81 82 25 100 34
output:
20 20 20 19 19
result:
ok 5 lines
Test #18:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
89 1 1
output:
1
result:
ok single line: '1'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
99 3 52 77 72
output:
33 33 33
result:
ok 3 lines