# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
334612 | 2020-12-09T15:01:43 Z | beksultan04 | Gift (IZhO18_nicegift) | C++14 | 131 ms | 5740 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define OK puts("OK"); #define fr first #define sc second #define ret return #define scan1(a) scanf("%lld",&a); #define scan2(a,b) scanf("%lld %lld",&a, &b); #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define all(s) s.begin(),s.end() #define pb push_back #define endi puts(""); const int N = 1e5+12,INF=1e9+7; vector <pii> v[N]; vector <int> ans[N]; int q[N]; main(){ int n,k,i,j,sum=0,cnt=0,mx=0,aa=0; scan2(n,k) for (i=0;i<n;++i) scan1(q[i]); for (i=0;i<n;++i){ mx = max(mx,q[i]); sum+=q[i]; } if (mx*k > sum || sum%k){ cout <<-1; ret 0; } else { int sz = sum/k,c=0; for (i=0;i<n;++i){ if (c+q[i] >= sz){ int x = c+q[i]-sz; v[cnt++].pb({q[i]-x,i+1}); c = (q[i]+c)%sz; v[cnt].pb({c,i+1}); } else { c+=q[i]; v[cnt].pb({q[i],i+1}); } } bool f=1; while (f){ f=0; int mn = INF; for (i=0;i<k;++i){ mn = min(mn,v[i].back().fr); } ans[aa].pb(mn); for (i=0;i<k;++i){ pii x = v[i].back(); v[i].pop_back(); x.fr -= mn; ans[aa].pb(x.sc); if (x.fr > 0){ v[i].pb(x); f=1; } } aa++; } cout <<aa<<"\n"; for (i=0;i<aa;++i){ for (j=0;j<ans[i].size();++j){ cout <<ans[i][j]<<" "; } endi } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4972 KB | n=4 |
2 | Correct | 5 ms | 4972 KB | n=3 |
3 | Correct | 4 ms | 4972 KB | n=3 |
4 | Incorrect | 5 ms | 4972 KB | Not all heaps are empty in the end |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4972 KB | n=4 |
2 | Correct | 5 ms | 4972 KB | n=3 |
3 | Correct | 4 ms | 4972 KB | n=3 |
4 | Incorrect | 5 ms | 4972 KB | Not all heaps are empty in the end |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4972 KB | n=4 |
2 | Correct | 5 ms | 4972 KB | n=3 |
3 | Correct | 4 ms | 4972 KB | n=3 |
4 | Incorrect | 5 ms | 4972 KB | Not all heaps are empty in the end |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 131 ms | 5740 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4972 KB | n=4 |
2 | Correct | 5 ms | 4972 KB | n=3 |
3 | Correct | 4 ms | 4972 KB | n=3 |
4 | Incorrect | 5 ms | 4972 KB | Not all heaps are empty in the end |
5 | Halted | 0 ms | 0 KB | - |