# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
139952 | almogwald | Meetings (IOI18_meetings) | C++14 | 100 ms | 19600 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 <utility>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <iostream>
//#include "job.h"
#include "meetings.h"
#define fori(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<n;i++)
#define fort(i,m,n) for(int i=m;i<n;i++)
#define forib(i,n) for(int i=n-1;i>=0;i--)
#define fornb(i,n) for(int i=n-1;i>0;i--)
#define maxl 1e18
#define con continue;
typedef long long lol;
using namespace std;
typedef vector<int> veci;
typedef vector<lol> vecl;
typedef pair<lol,lol> point;
lol sum=0;
vecl minimum_costs(veci H, veci L,veci R) {
int n=H.size();
vector<vecl> x(20,vecl(n));
x[0][0]= 2-H[0];
forn(i,n){
if(H[i]==1){
x[0][i]=x[0][i-1]+1;
}
}
forn(i,20){
fori(j,n/2){
x[i][j]=max(x[i-1][2*j],x[i-1][2*j+1]);
}
}
veci arr(n);
arr[n-1]= n+1-H[n-1];
forib(i,n-1){
arr[i]=i;
if(H[i]==1){
arr[i]=arr[i+1];
}
}
vecl C(L.size());
fori(i,C.size()){
int l=L[i];
int r=R[i];
if(arr[l]>r){
C[i]=r-l+1;
con
}
C[i]=arr[l]-l;
l=arr[l];
int k=0;
while(l+(1<<k)<=r+1){
if(l&(1<<k)){
C[i]=max(C[i],x[k][l>>k]);
l+=1<<k;
}
k++;
}
while(k>=0){
if(l+(1<<k)<=r+1){
C[i]=max(C[i],x[k][l>>k]);
l+=1<<k;
}
k--;
}
C[i]=2*(R[i]-L[i]+1) - C[i];
}
return C;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |