# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92789 | 2019-01-04T14:25:52 Z | Vardanyan | Gift (IZhO18_nicegift) | C++14 | 1348 ms | 120272 KB |
#include<bits/stdc++.h> using namespace std; const long long N = 1000*1000+5; pair<long long,long long> a[N]; int main() { long long n,k; scanf("%lld%lld",&n,&k); long long sum = 0; long long mns = 1; set<pair<long long,long long >,greater<pair<long long,long long> > > ms; for(long long i = 1;i<=n;i++){ scanf("%lld",&a[i].first); a[i].second = i; sum+=a[i].first; ms.insert(a[i]); } sort(a+1,a+1+n); if(sum>1000*100){ long long x = k/__gcd(n,k); if(a[n].first%x){ printf("-1\n"); return 0; } mns = a[n].first/x; } vector<vector<long long> > ans; while(1){ long long kk = k; vector<long long> now; set<pair<long long,long long> >::iterator it = ms.begin(); vector<pair<long long,long long> > add; for(;it!=ms.end();it++){ pair<long long,long long> x = *it; if(x.first-mns<0){ printf("-1\n"); return 0; } //x.first--; sum-=mns; now.push_back(x.second); kk--; add.push_back(x); if(kk == 0) break; } for(long long i = 0;i<add.size();i++){ ms.erase(ms.find(add[i])); add[i].first-=mns; ms.insert(add[i]); } ans.push_back(now); if(sum == 0) break; } printf("%lld\n",ans.size()); for(long long i = 0;i<ans.size();i++){ printf("%lld ",mns); for(long long j = 0;j<ans[i].size();j++){ printf("%lld ",ans[i][j]); } printf("\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 376 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 376 KB | n=4 |
6 | Correct | 2 ms | 376 KB | n=2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 376 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 376 KB | n=4 |
6 | Correct | 2 ms | 376 KB | n=2 |
7 | Correct | 2 ms | 256 KB | n=5 |
8 | Correct | 5 ms | 1016 KB | n=8 |
9 | Correct | 11 ms | 1204 KB | n=14 |
10 | Correct | 7 ms | 1016 KB | n=11 |
11 | Correct | 79 ms | 7720 KB | n=50000 |
12 | Correct | 75 ms | 7692 KB | n=50000 |
13 | Correct | 32 ms | 3496 KB | n=10 |
14 | Correct | 32 ms | 3116 KB | n=685 |
15 | Correct | 35 ms | 3324 KB | n=623 |
16 | Correct | 20 ms | 2036 KB | n=973 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 376 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 376 KB | n=4 |
6 | Correct | 2 ms | 376 KB | n=2 |
7 | Correct | 2 ms | 256 KB | n=5 |
8 | Correct | 5 ms | 1016 KB | n=8 |
9 | Correct | 11 ms | 1204 KB | n=14 |
10 | Correct | 7 ms | 1016 KB | n=11 |
11 | Correct | 79 ms | 7720 KB | n=50000 |
12 | Correct | 75 ms | 7692 KB | n=50000 |
13 | Correct | 32 ms | 3496 KB | n=10 |
14 | Correct | 32 ms | 3116 KB | n=685 |
15 | Correct | 35 ms | 3324 KB | n=623 |
16 | Correct | 20 ms | 2036 KB | n=973 |
17 | Correct | 36 ms | 2608 KB | n=989 |
18 | Correct | 16 ms | 1272 KB | n=563 |
19 | Correct | 25 ms | 1656 KB | n=592 |
20 | Correct | 26 ms | 1784 KB | n=938 |
21 | Correct | 21 ms | 1528 KB | n=747 |
22 | Correct | 23 ms | 1528 KB | n=991 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1328 ms | 120272 KB | n=1000000 |
2 | Correct | 856 ms | 81708 KB | n=666666 |
3 | Correct | 499 ms | 46632 KB | n=400000 |
4 | Correct | 1348 ms | 68324 KB | n=285714 |
5 | Correct | 18 ms | 2424 KB | n=20000 |
6 | Correct | 1197 ms | 53548 KB | n=181818 |
7 | Correct | 9 ms | 1400 KB | n=10000 |
8 | Correct | 108 ms | 5240 KB | n=6666 |
9 | Correct | 5 ms | 760 KB | n=4000 |
10 | Correct | 522 ms | 25592 KB | n=2857 |
11 | Correct | 3 ms | 604 KB | n=2000 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 376 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 376 KB | n=4 |
6 | Correct | 2 ms | 376 KB | n=2 |
7 | Correct | 2 ms | 256 KB | n=5 |
8 | Correct | 5 ms | 1016 KB | n=8 |
9 | Correct | 11 ms | 1204 KB | n=14 |
10 | Correct | 7 ms | 1016 KB | n=11 |
11 | Correct | 79 ms | 7720 KB | n=50000 |
12 | Correct | 75 ms | 7692 KB | n=50000 |
13 | Correct | 32 ms | 3496 KB | n=10 |
14 | Correct | 32 ms | 3116 KB | n=685 |
15 | Correct | 35 ms | 3324 KB | n=623 |
16 | Correct | 20 ms | 2036 KB | n=973 |
17 | Correct | 36 ms | 2608 KB | n=989 |
18 | Correct | 16 ms | 1272 KB | n=563 |
19 | Correct | 25 ms | 1656 KB | n=592 |
20 | Correct | 26 ms | 1784 KB | n=938 |
21 | Correct | 21 ms | 1528 KB | n=747 |
22 | Correct | 23 ms | 1528 KB | n=991 |
23 | Correct | 1328 ms | 120272 KB | n=1000000 |
24 | Correct | 856 ms | 81708 KB | n=666666 |
25 | Correct | 499 ms | 46632 KB | n=400000 |
26 | Correct | 1348 ms | 68324 KB | n=285714 |
27 | Correct | 18 ms | 2424 KB | n=20000 |
28 | Correct | 1197 ms | 53548 KB | n=181818 |
29 | Correct | 9 ms | 1400 KB | n=10000 |
30 | Correct | 108 ms | 5240 KB | n=6666 |
31 | Correct | 5 ms | 760 KB | n=4000 |
32 | Correct | 522 ms | 25592 KB | n=2857 |
33 | Correct | 3 ms | 604 KB | n=2000 |
34 | Incorrect | 14 ms | 2296 KB | Jury has the answer but participant has not |
35 | Halted | 0 ms | 0 KB | - |