Submission #1107083

#TimeUsernameProblemLanguageResultExecution timeMemory
1107083AvianshTeams (IOI15_teams)C++17
34 / 100
4061 ms20008 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; vector<int> nums[100005]; int nr; void init(int n, int a[], int b[]) { nr=n; for(int i = 0;i<n;i++){ nums[a[i]].push_back(b[i]); } } int can(int m, int k[]) { int knum[100005]; fill(knum,knum+100005,0); long long sm = 0; for(int i = 0;i<m;i++){ knum[k[i]]++; sm+=k[i]; } if(sm>nr){ return 0; } priority_queue<int,vector<int>,greater<int>>pq; for(int i = 0;i<100005;i++){ for(int e : nums[i]){ pq.push(e); } if(pq.size()<knum[i]*i){ return 0; } else{ for(int j = 0;j<knum[i];j++){ for(int k = 0;k<i;k++){ pq.pop(); } } } while(pq.size()&&pq.top()==i){ pq.pop(); } } return 1; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:31:21: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, std::greater<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |         if(pq.size()<knum[i]*i){
      |            ~~~~~~~~~^~~~~~~~~~
teams.cpp:36:25: warning: declaration of 'int k' shadows a parameter [-Wshadow]
   36 |                 for(int k = 0;k<i;k++){
      |                         ^
teams.cpp:15:20: note: shadowed declaration is here
   15 | int can(int m, int k[]) {
      |                ~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...