# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
726672 | 2023-04-19T08:52:41 Z | fdnfksd | Gift (IZhO18_nicegift) | C++14 | 263 ms | 22568 KB |
#include<bits/stdc++.h> #define TASKNAME "codeforce" #define pb push_back #define pli pair<int,int> #define fi first #define se second #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); using namespace std; using ll=long long; const ll maxN=2e6+10; const ll inf=1e18; const ll mod=1e9+7; ll n,k,a[maxN]; void solve() { cin >> n >> k; ll sum=0; for(int i=1;i<=n;i++) { cin >> a[i]; sum+=a[i]; } if(sum<=1e5) { priority_queue<pli> pq; for(int i=1;i<=n;i++) pq.push({a[i],i}); vector<pli> vc; vc.resize(k); vector<vector<ll>> ans; while(pq.size()>=k) { vector<ll> vd; vd.pb(1); for(int i=0;i<k;i++) { vc[i]=pq.top(); pq.pop(); vc[i].fi--; vd.pb(vc[i].se); } sum-=k; ans.pb(vd); for(int i=0;i<k;i++) { if(vc[i].fi>0) pq.push(vc[i]); } } if(sum==0) { cout << ans.size()<<'\n'; for(auto vec:ans) { for(auto zz:vec) cout << zz<<' '; cout << '\n'; } } else cout << -1; } else { for(int i=1;i<n;i++) { if(a[i]!=a[i+1]) { cout << -1; return; } } if(a[1]*n%k!=0) cout << -1; else { ll x=-1,y=-1; for(int i=1;i<=k;i++) { if(k%i==0&&n%i==0&&a[1]%(k/i)==0) { x=i; y=k/i; } } if(x==-1) {cout << -1;return;} ll s=1; for(int i=1;i<=n/x;i++) { cout << a[1]/y<<' '; ll cnt=k; while(cnt--) { cout << s<<' '; s=s+1; if(s>n) s-=n; } cout << '\n'; } } } } int main() { fastio //freopen(TASKNAME".INP","r",stdin); //freopen(TASKNAME".OUT","w",stdout); solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | n=4 |
2 | Correct | 0 ms | 212 KB | n=3 |
3 | Correct | 0 ms | 212 KB | n=3 |
4 | Correct | 0 ms | 212 KB | n=4 |
5 | Correct | 0 ms | 212 KB | n=4 |
6 | Correct | 0 ms | 212 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | n=4 |
2 | Correct | 0 ms | 212 KB | n=3 |
3 | Correct | 0 ms | 212 KB | n=3 |
4 | Correct | 0 ms | 212 KB | n=4 |
5 | Correct | 0 ms | 212 KB | n=4 |
6 | Correct | 0 ms | 212 KB | n=2 |
7 | Correct | 1 ms | 212 KB | n=5 |
8 | Correct | 2 ms | 980 KB | n=8 |
9 | Correct | 7 ms | 1168 KB | n=14 |
10 | Correct | 4 ms | 980 KB | n=11 |
11 | Correct | 34 ms | 4592 KB | n=50000 |
12 | Correct | 31 ms | 4548 KB | n=50000 |
13 | Correct | 23 ms | 3452 KB | n=10 |
14 | Correct | 24 ms | 3084 KB | n=685 |
15 | Correct | 26 ms | 3472 KB | n=623 |
16 | Correct | 17 ms | 1932 KB | n=973 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | n=4 |
2 | Correct | 0 ms | 212 KB | n=3 |
3 | Correct | 0 ms | 212 KB | n=3 |
4 | Correct | 0 ms | 212 KB | n=4 |
5 | Correct | 0 ms | 212 KB | n=4 |
6 | Correct | 0 ms | 212 KB | n=2 |
7 | Correct | 1 ms | 212 KB | n=5 |
8 | Correct | 2 ms | 980 KB | n=8 |
9 | Correct | 7 ms | 1168 KB | n=14 |
10 | Correct | 4 ms | 980 KB | n=11 |
11 | Correct | 34 ms | 4592 KB | n=50000 |
12 | Correct | 31 ms | 4548 KB | n=50000 |
13 | Correct | 23 ms | 3452 KB | n=10 |
14 | Correct | 24 ms | 3084 KB | n=685 |
15 | Correct | 26 ms | 3472 KB | n=623 |
16 | Correct | 17 ms | 1932 KB | n=973 |
17 | Correct | 22 ms | 2956 KB | n=989 |
18 | Correct | 10 ms | 1236 KB | n=563 |
19 | Correct | 16 ms | 1684 KB | n=592 |
20 | Correct | 17 ms | 1692 KB | n=938 |
21 | Correct | 17 ms | 1356 KB | n=747 |
22 | Correct | 14 ms | 1492 KB | n=991 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 263 ms | 22568 KB | Expected int32, but "1000000000000" found |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | n=4 |
2 | Correct | 0 ms | 212 KB | n=3 |
3 | Correct | 0 ms | 212 KB | n=3 |
4 | Correct | 0 ms | 212 KB | n=4 |
5 | Correct | 0 ms | 212 KB | n=4 |
6 | Correct | 0 ms | 212 KB | n=2 |
7 | Correct | 1 ms | 212 KB | n=5 |
8 | Correct | 2 ms | 980 KB | n=8 |
9 | Correct | 7 ms | 1168 KB | n=14 |
10 | Correct | 4 ms | 980 KB | n=11 |
11 | Correct | 34 ms | 4592 KB | n=50000 |
12 | Correct | 31 ms | 4548 KB | n=50000 |
13 | Correct | 23 ms | 3452 KB | n=10 |
14 | Correct | 24 ms | 3084 KB | n=685 |
15 | Correct | 26 ms | 3472 KB | n=623 |
16 | Correct | 17 ms | 1932 KB | n=973 |
17 | Correct | 22 ms | 2956 KB | n=989 |
18 | Correct | 10 ms | 1236 KB | n=563 |
19 | Correct | 16 ms | 1684 KB | n=592 |
20 | Correct | 17 ms | 1692 KB | n=938 |
21 | Correct | 17 ms | 1356 KB | n=747 |
22 | Correct | 14 ms | 1492 KB | n=991 |
23 | Incorrect | 263 ms | 22568 KB | Expected int32, but "1000000000000" found |
24 | Halted | 0 ms | 0 KB | - |