# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
347082 | 2021-01-11T17:08:16 Z | andrii | Gift (IZhO18_nicegift) | C++14 | 2000 ms | 283848 KB |
// -- // #include <bits/stdc++.h> #define pll pair<ll, ll> #define x first #define y second using namespace std; typedef long long ll; const ll N = 1e6+228; const ll inf = 0x3fff3fff3fff3fff; pll a[N]; vector<pair<ll, vector<ll>>> qrs; ll us[N]; signed main(){ cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); ll n, k, sai=0; cin >> n >> k; for(ll i = 0;i<n;i++){ cin >> a[i].x; a[i].y=i; sai+=a[i].x; } sort(a, a+n, greater<pll>()); if(sai%k) return cout<<-1, 0; set<pll, greater<pll>> allow; for(ll i = 0;i<n;i++) allow.insert({a[i].x, i}); for(;!allow.empty();){ if(allow.size()<k) return cout<<-1, 0; vector<ll> qk; ll mv= inf; for(ll i = 0;i<k;i++){ qk.push_back(allow.begin()->second); mv=allow.begin()->first; allow.erase(allow.begin()); } if(!allow.empty()) mv=mv-allow.begin()->first; mv=max(mv, 1ll); for(auto i : qk){ us[i]+=mv; if(us[i]<a[i].x) allow.insert({a[i].x-us[i], i}); } qrs.push_back({mv, qk}); } cout<<qrs.size()<<'\n'; for(auto i :qrs){ cout<<i.x<<' '; for(auto j : i.y) cout<<a[j].y+1<<' '; cout<<'\n'; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | n=4 |
2 | Correct | 0 ms | 364 KB | n=3 |
3 | Correct | 0 ms | 364 KB | n=3 |
4 | Correct | 0 ms | 364 KB | n=4 |
5 | Correct | 0 ms | 364 KB | n=4 |
6 | Correct | 0 ms | 364 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | n=4 |
2 | Correct | 0 ms | 364 KB | n=3 |
3 | Correct | 0 ms | 364 KB | n=3 |
4 | Correct | 0 ms | 364 KB | n=4 |
5 | Correct | 0 ms | 364 KB | n=4 |
6 | Correct | 0 ms | 364 KB | n=2 |
7 | Correct | 0 ms | 364 KB | n=5 |
8 | Correct | 1 ms | 492 KB | n=8 |
9 | Correct | 9 ms | 1256 KB | n=14 |
10 | Correct | 5 ms | 876 KB | n=11 |
11 | Correct | 36 ms | 6240 KB | n=50000 |
12 | Correct | 52 ms | 7772 KB | n=50000 |
13 | Correct | 25 ms | 3428 KB | n=10 |
14 | Correct | 34 ms | 3552 KB | n=685 |
15 | Correct | 34 ms | 3804 KB | n=623 |
16 | Correct | 19 ms | 2272 KB | n=973 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | n=4 |
2 | Correct | 0 ms | 364 KB | n=3 |
3 | Correct | 0 ms | 364 KB | n=3 |
4 | Correct | 0 ms | 364 KB | n=4 |
5 | Correct | 0 ms | 364 KB | n=4 |
6 | Correct | 0 ms | 364 KB | n=2 |
7 | Correct | 0 ms | 364 KB | n=5 |
8 | Correct | 1 ms | 492 KB | n=8 |
9 | Correct | 9 ms | 1256 KB | n=14 |
10 | Correct | 5 ms | 876 KB | n=11 |
11 | Correct | 36 ms | 6240 KB | n=50000 |
12 | Correct | 52 ms | 7772 KB | n=50000 |
13 | Correct | 25 ms | 3428 KB | n=10 |
14 | Correct | 34 ms | 3552 KB | n=685 |
15 | Correct | 34 ms | 3804 KB | n=623 |
16 | Correct | 19 ms | 2272 KB | n=973 |
17 | Correct | 32 ms | 2912 KB | n=989 |
18 | Correct | 15 ms | 1384 KB | n=563 |
19 | Correct | 22 ms | 1768 KB | n=592 |
20 | Correct | 23 ms | 1768 KB | n=938 |
21 | Correct | 19 ms | 1608 KB | n=747 |
22 | Correct | 23 ms | 1640 KB | n=991 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2085 ms | 283848 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | n=4 |
2 | Correct | 0 ms | 364 KB | n=3 |
3 | Correct | 0 ms | 364 KB | n=3 |
4 | Correct | 0 ms | 364 KB | n=4 |
5 | Correct | 0 ms | 364 KB | n=4 |
6 | Correct | 0 ms | 364 KB | n=2 |
7 | Correct | 0 ms | 364 KB | n=5 |
8 | Correct | 1 ms | 492 KB | n=8 |
9 | Correct | 9 ms | 1256 KB | n=14 |
10 | Correct | 5 ms | 876 KB | n=11 |
11 | Correct | 36 ms | 6240 KB | n=50000 |
12 | Correct | 52 ms | 7772 KB | n=50000 |
13 | Correct | 25 ms | 3428 KB | n=10 |
14 | Correct | 34 ms | 3552 KB | n=685 |
15 | Correct | 34 ms | 3804 KB | n=623 |
16 | Correct | 19 ms | 2272 KB | n=973 |
17 | Correct | 32 ms | 2912 KB | n=989 |
18 | Correct | 15 ms | 1384 KB | n=563 |
19 | Correct | 22 ms | 1768 KB | n=592 |
20 | Correct | 23 ms | 1768 KB | n=938 |
21 | Correct | 19 ms | 1608 KB | n=747 |
22 | Correct | 23 ms | 1640 KB | n=991 |
23 | Execution timed out | 2085 ms | 283848 KB | Time limit exceeded |
24 | Halted | 0 ms | 0 KB | - |