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"
//# pragma GCC optimize("Ofast,no-stack-protector")
//# pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
# pragma GCC optimize("Ofast")
# pragma GCC optimization ("unroll-loops")
# include "bits/stdc++.h"
/*
# include <ext/pb_ds/tree_policy.hpp>
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/rope>
*/
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;
int n,dp[1 << 16][16];
#undef int
long long plan_roller_coaster(vector<int> s, vector<int> t)
{
#define int ll
n = sz(s);
for(int mask = 0;mask < (1 << n);mask++)
{
for(int i = 0;i < n;i++) dp[mask][i] = 1e18;
}
for(int i = 0;i < n;i++) dp[(1 << i)][i] = 0;
for(int mask = 1;mask < (1 << n);mask++)
{
for(int last = 0;last < n;last++)
{
for(int newlast = 0;newlast < n;newlast++)
{
dp[mask | (1 << newlast)][newlast] = min(dp[mask | (1 << newlast)][newlast],dp[mask][last] + max(0,t[last] - s[newlast]));
}
}
}
int ans = 1e18;
for(int i = 0;i < n;i++) ans = min(ans,dp[(1 << n) - 1][i]);
return ans;
}
Compilation message (stderr)
railroad.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
# pragma GCC optimization ("unroll-loops")
# | 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... |