Submission #1214168

#TimeUsernameProblemLanguageResultExecution timeMemory
1214168salmonCookies (JOI23_cookies)C++20
7 / 100
3 ms840 KiB
#include <bits/stdc++.h> using namespace std; int N; int M; int lst[15100]; int B[15100]; int from[15100]; vector<int> memo[15100]; priority_queue<pair<int,int>> pq; int main(){ scanf(" %d",&N); int big = 0; int b = 0; for(int i = 1; i <= N; i++){ scanf(" %d",&lst[i]); big = max(lst[i],big); b += lst[i]; } scanf(" %d",&M); for(int i = 1; i <= M; i++){ scanf(" %d",&B[i]); } B[M + 1] = b + 1; for(int i = 0; i <= b; i++){ from[i] = -1; } vector<int> temp; for(int i = 1; i <= N; i++){ pq.push({lst[i],i}); } if(b % B[1] != 0 || big * B[1] > b){ printf("-1"); } else{ printf("%d\n",b / B[1]); for(int i = 0; i < b / B[1]; i++){ vector<pair<int,int>> v; printf("%d ",B[1]); for(int j = 0; j < B[1]; j++){ v.push_back(pq.top()); pq.pop(); } for(int j = 0; j < B[1]; j++){ if(v[j].first != 1){ pq.push({v[j].first - 1,v[j].second}); } printf("%d ",v[j].second); } printf("\n"); } } }

Compilation message (stderr)

cookies.cpp: In function 'int main()':
cookies.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf(" %d",&N);
      |         ~~~~~^~~~~~~~~~
cookies.cpp:20:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |                 scanf(" %d",&lst[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~
cookies.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf(" %d",&M);
      |         ~~~~~^~~~~~~~~~
cookies.cpp:28:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |                 scanf(" %d",&B[i]);
      |                 ~~~~~^~~~~~~~~~~~~
#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...