Submission #130623

#TimeUsernameProblemLanguageResultExecution timeMemory
130623mahmoudbadawyTeams (IOI15_teams)C++17
34 / 100
4046 ms23264 KiB
#include "teams.h" #include <bits/stdc++.h> #define F first #define S second using namespace std; const int N=5e5; vector< pair<int,int> > v; int a[N],b[N]; int n; void init(int nn, int A[], int B[]) { n=nn; for(int i=0;i<n;i++) a[i]=A[i],b[i]=B[i]; } multiset< int > ss; int can(int m, int k[]) { v.clear(); ss.clear(); for(int i=0;i<n;i++) { v.push_back({a[i],-(i+1)}); v.push_back({b[i],i+1}); } for(int i=0;i<m;i++) { v.push_back({k[i],0}); } sort(v.begin(),v.end()); for(int i=0;i<v.size();i++) { if(v[i].S<0) { ss.insert(b[-v[i].S-1]); } else if(v[i].S>0) { if(ss.find(b[v[i].S-1])!=ss.end()) ss.erase(ss.find(b[v[i].S-1])); } else { int x=v[i].F; while(x--){ auto it=ss.lower_bound(v[i].F); if(it==ss.end()) return 0; ss.erase(it); } } } return 1; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:33:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v.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...