-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbee3041.cpp
More file actions
49 lines (38 loc) · 863 Bytes
/
Copy pathbee3041.cpp
File metadata and controls
49 lines (38 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* Contest : Beecrowd
* Problem : 3041 - Distribuição de Artigos
* Link : https://judge.beecrowd.com/pt/problems/view/3041
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fastio ios::sync_with_stdio(0); cin.tie(0);
int main() {
fastio
int n;
while (cin >> n, n) {
vector<int> limite(n);
for(auto& i : limite) cin >> i;
sort(limite.rbegin(), limite.rend());
int total = accumulate(limite.begin(), limite.end(), 0);
int a; cin >> a;
if (a > total) {
cout << "Impossible\n";
continue;
}
vector<int> revisores(n);
int i = 0;
while (a > 0) {
if (revisores[i] < limite[i]) {
revisores[i]++;
a--;
i = (i+1) % n;
}
else
i = 0;
}
for (auto& i : revisores)
cout << i << '\n';
}
return 0;
}