Submission #1037835

# Submission time Handle Problem Language Result Execution time Memory
1037835 2024-07-29T09:00:24 Z 변재우(#10984) Cookies (JOI23_cookies) C++17
0 / 100
0 ms 348 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] || (tot/B[1])<mx) {
        cout<<-1; return -1;
    }
    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 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution failed because the return code was nonzero
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 -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -