Submission #796349

# Submission time Handle Problem Language Result Execution time Memory
796349 2023-07-28T10:07:52 Z Johann Cookies (JOI23_cookies) C++14
7 / 100
3 ms 1108 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 + 1;
            cout << "\n";
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 3 ms 1108 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 3 ms 556 KB Output is correct
19 Correct 3 ms 596 KB Output is correct
20 Correct 2 ms 448 KB Output is correct
21 Correct 2 ms 448 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -