Submission #100109

# Submission time Handle Problem Language Result Execution time Memory
100109 2019-03-09T09:47:39 Z MvC Roller Coaster Railroad (IOI16_railroad) C++11
34 / 100
89 ms 8696 KB
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int i,j,p,n,nr,id,cst;
ll s[20],t[20],f[20][(1<<17)],ans=llinf;
ll plan_roller_coaster(vector<int>s,vector<int>t)
{
	n=(int)s.size();
	for(i=1;i<(1<<n);i++)
	{
		nr=0;
		for(j=0;j<n;j++)
		{
			f[j][i]=llinf;
			if(i&(1<<j))
			{
				nr++,id=j;
				for(p=0;p<n;p++)
				{
					if(i&(1<<p) && p!=j)
					{
						cst=max(t[p]-s[j],0);
						f[j][i]=min(f[j][i],f[p][i^(1<<j)]+1LL*cst);
					}
				}
				if(i==(1<<n)-1)ans=min(ans,f[j][i]);
			}
		}
		if(nr==1)f[id][i]=0;
	}
	return ans;
}
/*int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	
    return 0;
}*/
/*
4
1 4 5 6
7 3 8 6
*/
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB n = 2
2 Correct 2 ms 256 KB n = 2
3 Correct 2 ms 428 KB n = 2
4 Correct 2 ms 256 KB n = 2
5 Correct 2 ms 256 KB n = 2
6 Correct 3 ms 384 KB n = 2
7 Correct 3 ms 384 KB n = 3
8 Correct 2 ms 384 KB n = 3
9 Correct 2 ms 384 KB n = 3
10 Correct 2 ms 384 KB n = 8
11 Correct 4 ms 384 KB n = 8
12 Correct 2 ms 384 KB n = 8
13 Correct 2 ms 384 KB n = 8
14 Correct 2 ms 384 KB n = 8
15 Correct 3 ms 412 KB n = 8
16 Correct 6 ms 384 KB n = 8
17 Correct 2 ms 384 KB n = 8
18 Correct 2 ms 384 KB n = 8
19 Correct 2 ms 384 KB n = 3
20 Correct 2 ms 384 KB n = 7
21 Correct 3 ms 428 KB n = 8
22 Correct 2 ms 384 KB n = 8
23 Correct 2 ms 384 KB n = 8
24 Correct 2 ms 384 KB n = 8
25 Correct 2 ms 384 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB n = 2
2 Correct 2 ms 256 KB n = 2
3 Correct 2 ms 428 KB n = 2
4 Correct 2 ms 256 KB n = 2
5 Correct 2 ms 256 KB n = 2
6 Correct 3 ms 384 KB n = 2
7 Correct 3 ms 384 KB n = 3
8 Correct 2 ms 384 KB n = 3
9 Correct 2 ms 384 KB n = 3
10 Correct 2 ms 384 KB n = 8
11 Correct 4 ms 384 KB n = 8
12 Correct 2 ms 384 KB n = 8
13 Correct 2 ms 384 KB n = 8
14 Correct 2 ms 384 KB n = 8
15 Correct 3 ms 412 KB n = 8
16 Correct 6 ms 384 KB n = 8
17 Correct 2 ms 384 KB n = 8
18 Correct 2 ms 384 KB n = 8
19 Correct 2 ms 384 KB n = 3
20 Correct 2 ms 384 KB n = 7
21 Correct 3 ms 428 KB n = 8
22 Correct 2 ms 384 KB n = 8
23 Correct 2 ms 384 KB n = 8
24 Correct 2 ms 384 KB n = 8
25 Correct 2 ms 384 KB n = 8
26 Correct 2 ms 384 KB n = 8
27 Correct 2 ms 384 KB n = 8
28 Correct 2 ms 384 KB n = 8
29 Correct 48 ms 8568 KB n = 16
30 Correct 49 ms 8624 KB n = 16
31 Correct 50 ms 8568 KB n = 16
32 Correct 56 ms 8568 KB n = 16
33 Correct 55 ms 8696 KB n = 16
34 Correct 63 ms 8568 KB n = 16
35 Correct 52 ms 8568 KB n = 16
36 Correct 22 ms 4224 KB n = 15
37 Correct 3 ms 384 KB n = 8
38 Correct 52 ms 8548 KB n = 16
39 Correct 71 ms 8668 KB n = 16
40 Correct 4 ms 384 KB n = 9
41 Correct 54 ms 8584 KB n = 16
42 Correct 48 ms 8568 KB n = 16
43 Correct 50 ms 8648 KB n = 16
44 Correct 3 ms 384 KB n = 9
45 Correct 28 ms 4216 KB n = 15
46 Correct 72 ms 8572 KB n = 16
47 Correct 69 ms 8568 KB n = 16
48 Correct 48 ms 8568 KB n = 16
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 3488 KB answer is not correct: 1 instead of 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB n = 2
2 Correct 2 ms 256 KB n = 2
3 Correct 2 ms 428 KB n = 2
4 Correct 2 ms 256 KB n = 2
5 Correct 2 ms 256 KB n = 2
6 Correct 3 ms 384 KB n = 2
7 Correct 3 ms 384 KB n = 3
8 Correct 2 ms 384 KB n = 3
9 Correct 2 ms 384 KB n = 3
10 Correct 2 ms 384 KB n = 8
11 Correct 4 ms 384 KB n = 8
12 Correct 2 ms 384 KB n = 8
13 Correct 2 ms 384 KB n = 8
14 Correct 2 ms 384 KB n = 8
15 Correct 3 ms 412 KB n = 8
16 Correct 6 ms 384 KB n = 8
17 Correct 2 ms 384 KB n = 8
18 Correct 2 ms 384 KB n = 8
19 Correct 2 ms 384 KB n = 3
20 Correct 2 ms 384 KB n = 7
21 Correct 3 ms 428 KB n = 8
22 Correct 2 ms 384 KB n = 8
23 Correct 2 ms 384 KB n = 8
24 Correct 2 ms 384 KB n = 8
25 Correct 2 ms 384 KB n = 8
26 Correct 2 ms 384 KB n = 8
27 Correct 2 ms 384 KB n = 8
28 Correct 2 ms 384 KB n = 8
29 Correct 48 ms 8568 KB n = 16
30 Correct 49 ms 8624 KB n = 16
31 Correct 50 ms 8568 KB n = 16
32 Correct 56 ms 8568 KB n = 16
33 Correct 55 ms 8696 KB n = 16
34 Correct 63 ms 8568 KB n = 16
35 Correct 52 ms 8568 KB n = 16
36 Correct 22 ms 4224 KB n = 15
37 Correct 3 ms 384 KB n = 8
38 Correct 52 ms 8548 KB n = 16
39 Correct 71 ms 8668 KB n = 16
40 Correct 4 ms 384 KB n = 9
41 Correct 54 ms 8584 KB n = 16
42 Correct 48 ms 8568 KB n = 16
43 Correct 50 ms 8648 KB n = 16
44 Correct 3 ms 384 KB n = 9
45 Correct 28 ms 4216 KB n = 15
46 Correct 72 ms 8572 KB n = 16
47 Correct 69 ms 8568 KB n = 16
48 Correct 48 ms 8568 KB n = 16
49 Incorrect 89 ms 3488 KB answer is not correct: 1 instead of 0
50 Halted 0 ms 0 KB -