Submission #1037729

# Submission time Handle Problem Language Result Execution time Memory
1037729 2024-07-29T07:27:22 Z 변재우(#10984) Cookies (JOI23_cookies) C++17
0 / 100
1 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=1; 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 600 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -