#pragma GCC diagnostic warning "-std=c++11"
#include <bits/stdc++.h>
#include "railroad.h"
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define flush fflush(stdout)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pii pair<int,int>
using namespace std;
int n,m,T,k,ans,fix[10];
vector<int> v,s,t;
void rec(int ind) {
if (ind==n) {
int sum=0;
for (int i=1; i<n; i++) {
if (t[v[i-1]]>s[v[i]]) {
sum+=t[v[i-1]]-s[v[i]];
}
}
ans=min(ans,sum);
return;
}
for (int i=0; i<n; i++) {
if (fix[i]==0) {
v.pb(i); fix[i]=1;
rec(ind+1);
v.pop_back(); fix[i]=0;
}
}
}
long long plan_roller_coaster(vector<int> S, vector<int> T) {
ans=1e18;
s=S; t=T;
n=s.size();
rec(0);
return ans;
}
Compilation message
railroad.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
1 | #pragma GCC diagnostic warning "-std=c++11"
| ^~~~~~~~~~~~
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:35:6: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
35 | ans=1e18;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
n = 2 |
2 |
Correct |
0 ms |
348 KB |
n = 2 |
3 |
Correct |
0 ms |
348 KB |
n = 2 |
4 |
Correct |
0 ms |
348 KB |
n = 2 |
5 |
Correct |
0 ms |
344 KB |
n = 2 |
6 |
Correct |
0 ms |
600 KB |
n = 2 |
7 |
Correct |
1 ms |
348 KB |
n = 3 |
8 |
Correct |
0 ms |
348 KB |
n = 3 |
9 |
Correct |
0 ms |
348 KB |
n = 3 |
10 |
Correct |
2 ms |
348 KB |
n = 8 |
11 |
Correct |
2 ms |
348 KB |
n = 8 |
12 |
Incorrect |
2 ms |
348 KB |
answer is not correct: -1568493664 instead of 2726473632 |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
n = 2 |
2 |
Correct |
0 ms |
348 KB |
n = 2 |
3 |
Correct |
0 ms |
348 KB |
n = 2 |
4 |
Correct |
0 ms |
348 KB |
n = 2 |
5 |
Correct |
0 ms |
344 KB |
n = 2 |
6 |
Correct |
0 ms |
600 KB |
n = 2 |
7 |
Correct |
1 ms |
348 KB |
n = 3 |
8 |
Correct |
0 ms |
348 KB |
n = 3 |
9 |
Correct |
0 ms |
348 KB |
n = 3 |
10 |
Correct |
2 ms |
348 KB |
n = 8 |
11 |
Correct |
2 ms |
348 KB |
n = 8 |
12 |
Incorrect |
2 ms |
348 KB |
answer is not correct: -1568493664 instead of 2726473632 |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
75 ms |
14264 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
n = 2 |
2 |
Correct |
0 ms |
348 KB |
n = 2 |
3 |
Correct |
0 ms |
348 KB |
n = 2 |
4 |
Correct |
0 ms |
348 KB |
n = 2 |
5 |
Correct |
0 ms |
344 KB |
n = 2 |
6 |
Correct |
0 ms |
600 KB |
n = 2 |
7 |
Correct |
1 ms |
348 KB |
n = 3 |
8 |
Correct |
0 ms |
348 KB |
n = 3 |
9 |
Correct |
0 ms |
348 KB |
n = 3 |
10 |
Correct |
2 ms |
348 KB |
n = 8 |
11 |
Correct |
2 ms |
348 KB |
n = 8 |
12 |
Incorrect |
2 ms |
348 KB |
answer is not correct: -1568493664 instead of 2726473632 |
13 |
Halted |
0 ms |
0 KB |
- |