Submission #796348

# Submission time Handle Problem Language Result Execution time Memory
796348 2023-07-28T10:07:32 Z Johann Cookies (JOI23_cookies) C++14
0 / 100
0 ms 212 KB
#include "bits/stdc++.h"
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

const int INF = 1 << 30;
int N, M;
vpii A;
vi B;
vi dp;
vi used;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;
    A.resize(N);
    int maxi = 0, sum = 0;
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i].first;
        maxi = max(maxi, A[i].first);
        sum += A[i].first;
        A[i].second = i;
    }

    cin >> M;
    B.resize(M);
    for (int i = 0; i < M; ++i)
        cin >> B[i];

    // sort(all(A));

    if (sum % B[0] != 0 || maxi * B[0] > sum)
    {
        cout << -1 << "\n";
    }
    else
    {
        vvi stuff(sum / B[0]);
        int idx = 0;
        for (int i = 0; i < N; ++i)
            for (int j = 0; j < A[i].first; ++j)
                stuff[(idx++) % sz(stuff)].push_back(i);
        cout << sz(stuff) << "\n";
        for (int i = 0; i < sz(stuff); ++i)
        {
            cout << sz(stuff[i]);
            for (int x : stuff[i])
                cout << " " << x;
            cout << "\n";
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer 0 violates the range [1, 7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Integer 0 violates the range [1, 1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer 0 violates the range [1, 7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer 0 violates the range [1, 7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer 0 violates the range [1, 7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer 0 violates the range [1, 7]
2 Halted 0 ms 0 KB -