# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1037842 |
2024-07-29T09:07:15 Z |
변재우(#10984) |
Cookies (JOI23_cookies) |
C++17 |
|
163 ms |
1372 KB |
#include <bits/stdc++.h>
using namespace std;
const int Nmax=15010;
int N, M, tot, mx, ans, A[Nmax], B[Nmax], X[Nmax];
vector<int> Y[Nmax];
vector<pair<int, int>> V, W;
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>N;
for(int i=1; i<=N; i++) cin>>A[i], tot+=A[i], mx=max(mx, A[i]);
cin>>M;
for(int i=1; i<=M; i++) cin>>B[i];
if(tot%B[1] || (tot/B[1])<mx) {
cout<<-1; return 0;
}
ans=tot/B[1];
for(int i=0; i<ans; i++) X[i]=B[1], V.push_back({B[1], i});
for(int i=1; i<=N; i++) W.push_back({A[i], i});
sort(W.rbegin(), W.rend());
for(int i=0; i<N; i++) {
sort(V.rbegin(), V.rend());
int cnt=0;
for(int j=0; j<ans; j++) {
if(V[j].first==0) continue;
cnt++, V[j].first--, Y[V[j].second].push_back(W[i].second);
if(cnt>=W[i].first) break;
}
if(cnt<W[i].first) {
return -1;
}
}
cout<<ans<<"\n";
for(int i=0; i<ans; i++) {
cout<<X[i]<<" ";
for(int j:Y[i]) cout<<j<<" ";
cout<<"\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
15 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
600 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
860 KB |
Output is correct |
10 |
Correct |
3 ms |
1372 KB |
Output is correct |
11 |
Correct |
0 ms |
604 KB |
Output is correct |
12 |
Correct |
0 ms |
604 KB |
Output is correct |
13 |
Correct |
0 ms |
604 KB |
Output is correct |
14 |
Correct |
0 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
604 KB |
Output is correct |
16 |
Correct |
0 ms |
604 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
3 ms |
856 KB |
Output is correct |
19 |
Correct |
163 ms |
1028 KB |
Output is correct |
20 |
Correct |
3 ms |
856 KB |
Output is correct |
21 |
Correct |
1 ms |
860 KB |
Output is correct |
22 |
Correct |
1 ms |
860 KB |
Output is correct |
23 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |