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 "railroad.h"
#include <bits/stdc++.h>
#define MAX 1000000000000000000
#define MIN -1
#define all(a) a.begin (), a.end ()
#define S second
#define F first
#define pb push_back
#define mp make_pair
using namespace std;
typedef vector <int> vi;
typedef long long int ll;
typedef pair <int , int> ii;
long long plan_roller_coaster(vector<int> s, vector<int> t) {
vector <ii> v;
int n=s.size ();
for(int i=0;i<n;i++){
v.pb(mp(s[i], t[i]));
}
sort(all(v));
//int n = (int) s.size();
ll mini=0;
for(int i=1;i<n;i++)mini+=max(0, v[i-1].S-v[i].F);
do{
ll acum=0;
//acum+=max(0, s[0]-1);
for(int i=1;i<n;i++){
acum+=max(0, v[i-1].S-v[i].F);
}
//cout<<acum<<endl;
/* for(int i=0;i<n;i++)cout<<v[i].F<<" ";
cout<<endl;
for(int i=0;i<n;i++)cout<<v[i].S<<" ";
cout<<endl<<endl;*/
mini=min(acum , mini);
}while(next_permutation(v.begin(), v.end ()));
return mini;
}/*
int main() {
int n;
assert(1 == scanf("%d", &n));
std::vector<int> s(n), t(n);
for (int i = 0; i < n; ++i)
assert(2 == scanf("%d%d", &s[i], &t[i]));
long long ans = plan_roller_coaster(s, t);
printf("%lld\n", ans);
return 0;
}*/
# | 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... |