# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
885400 | abcvuitunggio | Teams (IOI15_teams) | C++17 | 1580 ms | 45732 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;
int n,cnt[500001],a[500002],dp[1010][1010];
vector <int> v[500001];
void init(int N, int A[], int B[]){
n=N;
for (int i=0;i<n;i++){
a[A[i]]++;
a[B[i]+1]--;
v[A[i]].push_back(B[i]);
}
for (int i=1;i<=n;i++){
a[i]+=a[i-1];
sort(v[i].begin(),v[i].end());
}
}
int can(int M, int K[]){
int sum=0;
for (int i=0;i<M;i++){
sum+=K[i];
if (sum>n)
return 0;
}
vector <int> ve;
for (int i=0;i<M;i++){
cnt[K[i]]++;
if (cnt[K[i]]==1)
ve.push_back(K[i]);
}
ve.push_back(0);
sort(ve.begin(),ve.end());
int mx=0;
for (int j=ve.size()-1;j>=0;j--){
int cur=-a[ve[j]];
for (int i=0;i<j;i++){
cur+=v[i].size()-(lower_bound(v[i].begin(),v[i].end(),ve[j])-v[i].begin());
dp[i][j]=max(dp[i][j+1],dp[j][j+1]+ve[j]*cnt[ve[j]]+cur);
if (!i)
mx=max(mx,dp[i][j]);
}
}
for (int i=ve.size()-1;i>=0;i--)
for (int j=ve.size()-1;j>i;j--)
dp[i][j]=0;
for (int i=0;i<M;i++)
cnt[K[i]]=0;
return (!mx);
}
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... |