Submission #909538

#TimeUsernameProblemLanguageResultExecution timeMemory
909538LucaIlieCookies (JOI23_cookies)C++17
7 / 100
4 ms1116 KiB
#include <bits/stdc++.h> using namespace std; struct cookieType { int count, type; }; const int MAX_N = 15000; const int MAX_M = 15000; cookieType cookies[MAX_N]; int boxsize[MAX_M]; vector<int> cookiesByBox[MAX_N]; int main() { int n, m; cin >> n; for ( int i = 0; i < n; i++ ) { cin >> cookies[i].count; cookies[i].type = i + 1; } cin >> m; for ( int i = 0; i < m; i++ ) cin >> boxsize[i]; int sumCookies = 0, maxCookies = 0; for ( int i = 0; i < n; i++ ) { sumCookies += cookies[i].count; maxCookies = max( maxCookies, cookies[i].count ); } int bs = boxsize[0]; if ( sumCookies % bs != 0 || maxCookies > sumCookies / bs ) { cout << -1; return 0; } sort( cookies, cookies + n, []( cookieType x, cookieType y ) { return x.count > y.count; } ); int b = sumCookies / bs, j = 0; for ( int i = 0; i < n; i++ ) { while ( cookies[i].count > 0 ) { cookiesByBox[j].push_back( cookies[i].type ); j = (j + 1) % b; cookies[i].count--; } } cout << b << "\n"; for ( int i = 0; i < b; i++ ) { cout << bs << " "; for ( int j: cookiesByBox[i] ) cout << j << " "; 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...