# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
802329 | Khizri | Teams (IOI15_teams) | C++17 | 4069 ms | 11504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "teams.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define OK cout<<"Ok"<<endl;
#define MOD (ll)(1e9+7)
const int mxn=2e5+5;
int n,x[mxn],y[mxn];
void init(int N, int A[], int B[]) {
n=N;
for(int i=0;i<n;i++){
x[i+1]=A[i];
y[i+1]=B[i];
}
}
bool cmp(pii a,pii b){
if(a.S==b.S){
return a.F>b.F;
}
return a.S<b.S;
}
int can(int m, int arr[]) {
sort(arr,arr+m);
vector<pii>vt;
for(int i=1;i<=n;i++){
vt.pb({x[i],y[i]});
}
ll sum=0;
for(int i=0;i<m;i++){
sum+=arr[i];
}
if(sum>n) return 0;
sort(all(vt));
for(int i=0;i<m;i++){
int cnt=arr[i];
int l=0,r=vt.size()-1;
while(l<=r){
int m=(l+r)/2;
if(vt[m].S>=arr[i]){
r=m-1;
}
else{
l=m+1;
}
}
for(int j=r+1;j<vt.size();j++){
if(!cnt) break;
if(vt[j].F<=arr[i]&&vt[j].S>=arr[i]){
vt.erase(vt.begin()+j);
j--;
cnt--;
}
}
if(cnt) return 0;
}
return 1;
}
/*
g++ teams.cpp grader.cpp ; .\a.exe
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |