이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define sz(x) (ll)x.size()
typedef vector <ll> vi;
typedef pair<ll,ll> ii;
typedef vector <ii> vii;
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
void printVct(vi &v){
for (ll i =0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
#define INF 1000000000000000000
ll plan_roller_coaster(vector <int> ss, vector<int> tt) {
ll n = sz(ss);
ll n2 = (1 << n);
vi s(n), t(n);
for(ll i =0; i<n; i++){
s[i] = ss[i];
t[i] = tt[i];
}
// printVct(t);
// printVct(s);
ll ans = INF;
vi v(n);
for (ll i =0; i<n; i++) v[i] = i;
do{
ll c = 0;
ll x = 1;
for (ll i =0; i<n; i++){
ll idx = v[i];
// dbg3(idx, c, x);
// dbg2(s[idx], t[idx]);
if (x > s[idx]){
c += x-s[idx];
}
x = t[idx];
}
// printVct(v);
// dbg(c);
ans = min(ans, c);
}while (next_permutation(v.begin(), v.end()));
return ans;
}
/*
4 1
1 7
4 3
5 8
6 6
*/
컴파일 시 표준 에러 (stderr) 메시지
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:31:8: warning: unused variable 'n2' [-Wunused-variable]
31 | ll n2 = (1 << n);
| ^~
# | 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... |