Submission #741643

#TimeUsernameProblemLanguageResultExecution timeMemory
741643MODDITeams (IOI15_teams)C++14
0 / 100
4070 ms16464 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); } class comp{ public: bool operator()(pii& a, pii& b){ if(a.second == b.second) return a.first > b.first; else return a.second > b.second; } }; 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()); priority_queue<pii, vector<pii>, comp> pq; 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); taken++; } if(taken < teams[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:30: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]
   30 |  for(int i = 0;  i< arr.size(); i++)
      |                  ~^~~~~~~~~~~~
teams.cpp:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  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...