# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
21794 | sbansalcs | Teams (IOI15_teams) | C++14 | 4000 ms | 13744 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 <stack>
#include <math.h>
#include <vector>
#include <assert.h>
#include <algorithm>
using namespace std;
const int N = 5e5+5;
int A[N],B[N];
int n;
int del[N];
int sz=0;
int dp[N];
void init(int _n, int a[], int b[]) {
n=_n;
for(int i=1;i<=n;i++) {
A[i]=a[i-1];
B[i]=b[i-1];
}
}
// int getUnder(int k, int y) {
// int tot=0;
// for(int i=1;i<=n;i++) {
// if(A[i]<=k && B[i]>=k) tot++;
// }
// for(int i=sz;i>=1;i--) {
// }
// }
// bool fx(int k) {
// return 1;
// }
int getCount(int a, int b) {
int tot=0;
for(int i=1;i<=n;i++) {
if(A[i]>a && A[i]<=b && B[i]>=b) tot++;
}
return tot;
}
int can(int M, int K[]) {
sort(K,K+M);
vector<pair<int,int>> vt;
for(int i=0;i<M;i++) {
if(vt.size()==0 || vt[vt.size()-1].first!=K[i]) {
vt.push_back({K[i],1});
}
else {
vt[vt.size()-1].second++;
}
}
int n2 = vt.size();
int h=sqrt(n);
assert(n2<=3*h);
int mini=0;
for(int i=0;i<n2;i++) {
dp[i]=getCount(0,vt[i].first)-vt[i].first*vt[i].second;
for(int j=0;j<i;j++) {
dp[i]=min(dp[i],dp[j]-vt[i].first*vt[i].second+getCount(vt[j].first,vt[i].first));
}
if(dp[i]<0) return 0;
}
return 1;
}
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... |