Submission #741641

#TimeUsernameProblemLanguageResultExecution timeMemory
741641MODDITeams (IOI15_teams)C++14
0 / 100
4016 ms20340 KiB
#include "teams.h" //#include "grader.cpp" #include <bits/stdc++.h> #define ll long long #define mp make_pair #define pb push_back #define pii pair<int,int> using namespace std; vector<pii> arr; void init(int N, int A[], int B[]) { for(int i = 0; i < N; i++){ arr.pb(mp(A[i], B[i])); } // sort(arr.begin(), arr.end(), comp); } int can(int M, int K[]) { vector<int> teams; for(int i = 0; i < M; i++) teams.pb(K[i]); sort(teams.begin(), teams.end()); auto comp = [](pii& a, pii& b){ return (a.second == b.second) ? a.first > b.first : a.second > b.second; }; priority_queue<pii, vector<pii>, decltype(comp)> pq(comp); for(int i = 0; i< arr.size(); i++) pq.push(arr[i]); for(int i = 0; i < teams.size(); i++){ int taken = 0; vector<pii> reuse; while(!pq.empty() && taken < teams[i]){ pii now = pq.top(); pq.pop(); if(teams[i] < now.first || teams[i] > now.second){ reuse.pb(now); continue; } taken++; } if(taken < i) return 0; for(auto t : reuse) pq.push(t); } return 1; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:27:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for(int i = 0;  i< arr.size(); i++)
      |                  ~^~~~~~~~~~~~
teams.cpp:30:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for(int i = 0; i < teams.size(); 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...