#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vi vector<int>
#define vp32 vector<p32>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MOD %1000000007
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using Tree =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//never guess
//never debug without reviewing code
//never try adding ones or subtracting them
//only step by step debug when necessary
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t){
int n = s.size();
ll dp [(int)1e5][n];
memset(dp,1,sizeof dp);
for(int i = 0; i<n; i++) dp[(1<<i)][i] = 0;
for(int mask = 1; mask<(1<<n); mask++){
for(int i = 0; i<n; i++){
if((1<<i)&mask){
int submask = mask-(1<<i);
for(int j = 0; j<n; j++){
if(submask&(1<<j)){
dp[mask][i] = min(dp[mask][i],dp[submask][j] + max(0,t[j]-s[i]));
}
}
}
}
}
return *min_element(dp[(1<<n)-1],dp[1<<n]);
}
long long aplan_roller_coaster(std::vector<int> s, std::vector<int> t) {
vp32 arr;
for(int i = 0; i<s.size(); i++) arr.eb(s[i],t[i]);
sort(arr.begin(),arr.end());
ll result = 1e12;
do{
ll res = 0;
for(int i = 1; i<arr.size(); i++){
res+=max(0,arr[i-1].se-arr[i].fi);
}
result = min(result,res);
}while(next_permutation(arr.begin(),arr.end()));
return result;
}
컴파일 시 표준 에러 (stderr) 메시지
railroad.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
railroad_c.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
# | 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... |