# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1117545 | heeheeheehaaw | Nile (IOI24_nile) | C++17 | 2049 ms | 14180 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 <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include "nile.h"
using namespace std;
struct art
{
long long w,a,b;
};
bool compare(art a,art b)
{
return a.w<b.w;
}
vector<art> artifact;
long long sol(vector<art> v,long long d)
{
long long price=0;
for(long long i=0;i<v.size();i++)
{
price+=v[i].b;
}
if((int)v.size()%2==0)
return price;
long long minn=999999999999999999;
for(long long i=0;i<v.size();i++)
{
if(((i==0) or (i==((int)v.size()-1))) or (abs(v[i - 1].w-v[i + 1].w)<=d) or (((i + 1) % 2) == 1))
minn=min(minn,(long long)(v[i].a-v[i].b));
}
return price+minn;
}
vector<long long> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E)
{
long long n = W.size();
for(long long i=0;i<n;i++)
{
art x;
x.w = W[i];
x.a = A[i];
x.b = B[i];
artifact.push_back(x);
}
sort(artifact.begin(),artifact.end(),compare);
long long q = E.size();
long long price=0;
vector<long long> R;
for(long long matale = 0; matale < q; matale++)
{
price=0;
long long d = E[matale];
vector<art> v;
v.push_back(artifact[0]);
for(long long i=1;i<artifact.size();i++)
{
if(abs(artifact[i-1].w-artifact[i].w)<=d)
v.push_back(artifact[i]);
else
price+=sol(v,d),v.clear(),v.push_back(artifact[i]);
}
price+=sol(v,d);
R.push_back(price);
}
return R;
}
/*
5
15 5 1
12 4 2
2 5 2
10 6 3
21 3 2
3
5 9 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... |
# | 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... |