# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1037731 |
2024-07-29T07:28:24 Z |
변재우(#10984) |
Cookies (JOI23_cookies) |
C++17 |
|
8 ms |
600 KB |
#include <bits/stdc++.h>
using namespace std;
const int Nmax=510;
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]) {
cout<<-1; return 0;
}
ans=tot/B[1];
for(int i=1; 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());
for(int j=0; j<A[W[i].second]; j++) {
V[j].first--, Y[V[j].second].push_back(W[i].second);
if(V[j].first<0) {
cout<<-1; return 0;
}
}
}
cout<<ans<<"\n";
for(int i=1; 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 |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
8 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int32 expected |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |