Submission #640178

#TimeUsernameProblemLanguageResultExecution timeMemory
640178BenmathTeams (IOI15_teams)C++14
34 / 100
4046 ms18132 KiB
#include <bits/stdc++.h> #include<teams.h> using namespace std; int n; int a[100001],b[100001]; void init(int N, int A[], int B[]) { n=N; vector<pair<int,int> >v; for(int i=0;i<N;i++){ v.push_back({A[i],B[i]}); } sort(v.begin(),v.end()); for(int i=0;i<N;i++){ a[i]=v[i].first; b[i]=v[i].second; } } int can(int M, int K[]) { priority_queue<int,vector<int>,greater<int> >pq; sort(K,K+M); //cout<<pq.top()<<endl; int j=0; for(int i=0;i<M;i++){ while(!pq.empty() and pq.top()<K[i]){ pq.pop(); } while(j<n){ if(K[i]>=a[j] and K[i]<=b[j]){ pq.push(b[j]); }else if(K[i]<a[j]){ break; } j++; } int t1=0; if(pq.size()<K[i]){ //cout<<i<<endl; return 0; }else{ for(int k1=0;k1<K[i];k1++){ pq.pop(); } } } return 1; } /* int main() { int n1; cin>>n1; int a1[n1],b1[n1]; for(int i=0;i<n1;i++){ cin>>a1[i]>>b1[i]; } init(n1,a1,b1); int q; cin>>q; for(int i=0;i<q;i++){ int m; cin>>m; int k[m]; for(int j=0;j<m;j++){ cin>>k[j]; } cout<<can(m,k)<<endl; } } */

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:39: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]
   39 |         if(pq.size()<K[i]){
      |            ~~~~~~~~~^~~~~
teams.cpp:38:13: warning: unused variable 't1' [-Wunused-variable]
   38 |         int t1=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...