Submission #204224

#TimeUsernameProblemLanguageResultExecution timeMemory
204224awlintqaaRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
99 ms26872 KiB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) #include <bits/stdc++.h> using namespace std; #define sqr 200 #define mid (l+r)/2 #define pb push_back #define ppb pop_back #define fi first #define se second #define lb lower_bound #define ub upper_bound #define ins insert #define era erase #define C continue #define mem(dp,i) memset(dp,i,sizeof(dp)) #define mset multiset typedef long long ll; typedef short int si; typedef long double ld; typedef pair<int,int> pi; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll; const ll mod=1e9+7; const ll inf= 4e18; const ld pai=acos(-1); #include "railroad.h" ll n ; ll dp[(1<<17)+9][19]; ll l[19],r[19]; ll calc(ll x , ll y ){ if ( x<=y)return 0; return x-y; } ll bt(int mask,int last){ if ( mask == (1<<(n+1)) -1 ) return 0; ll &ret=dp[mask][last]; if( ret != -1) return ret; ret = inf; for(int i =1 ;i <=n; i++){ if ( (mask&(1<<i) ) == 0 ){ ret = min ( ret ,bt ( mask|(1<<i) , i ) + calc(r[last],l[i] ) ); } } return ret; } long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { n = (int) s.size(); mem(dp,-1); r [0] = 1; for(int i = 0 ;i < n ;i ++ ) { l[i+1]=s[i]; r[i+1]=t[i]; } return bt(1,0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...