# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
347080 | 2021-01-11T17:06:41 Z | andrii | Gift (IZhO18_nicegift) | C++14 | 820 ms | 118056 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=allow.begin()->first; 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 | 1 ms | 364 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 1 ms | 384 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | n=4 |
2 | Correct | 1 ms | 364 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 1 ms | 384 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
7 | Correct | 1 ms | 364 KB | n=5 |
8 | Correct | 1 ms | 364 KB | n=8 |
9 | Correct | 1 ms | 364 KB | n=14 |
10 | Correct | 1 ms | 364 KB | n=11 |
11 | Correct | 36 ms | 6240 KB | n=50000 |
12 | Correct | 42 ms | 6136 KB | n=50000 |
13 | Correct | 1 ms | 364 KB | n=10 |
14 | Correct | 1 ms | 492 KB | n=685 |
15 | Correct | 1 ms | 492 KB | n=623 |
16 | Correct | 1 ms | 492 KB | n=973 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | n=4 |
2 | Correct | 1 ms | 364 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 1 ms | 384 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
7 | Correct | 1 ms | 364 KB | n=5 |
8 | Correct | 1 ms | 364 KB | n=8 |
9 | Correct | 1 ms | 364 KB | n=14 |
10 | Correct | 1 ms | 364 KB | n=11 |
11 | Correct | 36 ms | 6240 KB | n=50000 |
12 | Correct | 42 ms | 6136 KB | n=50000 |
13 | Correct | 1 ms | 364 KB | n=10 |
14 | Correct | 1 ms | 492 KB | n=685 |
15 | Correct | 1 ms | 492 KB | n=623 |
16 | Correct | 1 ms | 492 KB | n=973 |
17 | Correct | 1 ms | 512 KB | n=989 |
18 | Incorrect | 1 ms | 364 KB | Jury has the answer but participant has not |
19 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 820 ms | 118056 KB | n=1000000 |
2 | Correct | 495 ms | 74988 KB | n=666666 |
3 | Correct | 272 ms | 44140 KB | n=400000 |
4 | Incorrect | 154 ms | 30600 KB | Jury has the answer but participant has not |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | n=4 |
2 | Correct | 1 ms | 364 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 1 ms | 384 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
7 | Correct | 1 ms | 364 KB | n=5 |
8 | Correct | 1 ms | 364 KB | n=8 |
9 | Correct | 1 ms | 364 KB | n=14 |
10 | Correct | 1 ms | 364 KB | n=11 |
11 | Correct | 36 ms | 6240 KB | n=50000 |
12 | Correct | 42 ms | 6136 KB | n=50000 |
13 | Correct | 1 ms | 364 KB | n=10 |
14 | Correct | 1 ms | 492 KB | n=685 |
15 | Correct | 1 ms | 492 KB | n=623 |
16 | Correct | 1 ms | 492 KB | n=973 |
17 | Correct | 1 ms | 512 KB | n=989 |
18 | Incorrect | 1 ms | 364 KB | Jury has the answer but participant has not |
19 | Halted | 0 ms | 0 KB | - |