# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
378706 |
2021-03-17T03:25:13 Z |
balbit |
Gift (IZhO18_nicegift) |
C++14 |
|
542 ms |
46500 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define f first
#define s second
#define REP(i,n) for (int i = 0; i<n; ++i)
#define pii pair<int, int>
#define SZ(x) (int)((x).size())
#define ALL(x) x.begin(), x.end()
#define pb push_back
#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T && x, S && ...y){cerr<<x<<", "; _do(y...);}
#else
#define bug(...)
#define endl '\n'
#endif // BALBIT
const int maxn = 2e6+6;
ll a[maxn];
void GG(){cout<<-1<<endl; exit(0);}
int fr[maxn];
signed main(){
ios::sync_with_stdio(0), cin.tie(0);
bug(1,2);
ll n,k; cin>>n>>k;
ll sig = 0;
vector<pair<int, pii> > v;
ll now = 0, h = 0;
REP(i,n) {
cin>>a[i]; sig+=a[i];
}
if (sig % k != 0) {
GG();
}
ll gp = sig / k;
REP(i,n){
v.pb({now, {h, i}});
now += a[i];
bug(now, gp, h);
if (now >= gp) {
now -= gp; ++h;
if (now >= gp) GG();
if (now) {
v.pb({0, {h, i}});
}
}
}
int prv = 0;
v.pb({gp, {-1, -1}});
sort(ALL(v));
int fofo = 0;
REP(i,SZ(v)) {
if (v[i].f != prv) ++fofo;
prv = v[i].f;
}
cout<<fofo<<endl;
prv = 0;
for (auto e : v) {
int df = e.f - prv;
if (df) {
cout<<df<<' ';
REP(i,k) {
cout<<fr[i]<<' ';
}
cout<<'\n';
}
if(~e.s.f) {
fr[e.s.f] = e.s.s+1;
}
prv = e.f;
}
}
# |
Verdict |
Execution time |
Memory |
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 |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
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 |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Incorrect |
1 ms |
364 KB |
Same heap occurs twice |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Incorrect |
1 ms |
364 KB |
Same heap occurs twice |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
542 ms |
46500 KB |
n=1000000 |
2 |
Correct |
272 ms |
31308 KB |
n=666666 |
3 |
Correct |
156 ms |
17984 KB |
n=400000 |
4 |
Correct |
314 ms |
27200 KB |
n=285714 |
5 |
Correct |
8 ms |
1768 KB |
n=20000 |
6 |
Correct |
268 ms |
22352 KB |
n=181818 |
7 |
Correct |
5 ms |
1068 KB |
n=10000 |
8 |
Correct |
32 ms |
2476 KB |
n=6666 |
9 |
Correct |
2 ms |
620 KB |
n=4000 |
10 |
Correct |
176 ms |
10092 KB |
n=2857 |
11 |
Correct |
1 ms |
492 KB |
n=2000 |
# |
Verdict |
Execution time |
Memory |
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 |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Incorrect |
1 ms |
364 KB |
Same heap occurs twice |
9 |
Halted |
0 ms |
0 KB |
- |