Submission #796348

#TimeUsernameProblemLanguageResultExecution timeMemory
796348JohannCookies (JOI23_cookies)C++14
0 / 100
0 ms212 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...