Submission #526381

# Submission time Handle Problem Language Result Execution time Memory
526381 2022-02-14T14:09:47 Z mosiashvililuka Let's Win the Election (JOI22_ho_t3) C++14
56 / 100
1033 ms 18500 KB
#include<bits/stdc++.h>
using namespace std;
const int N=2009;
int a,b,c,d,e,i,j,ii,jj,zx,xc,K,fx[509],PI,T;
pair <pair <int, int>, int> p[509];
pair <int, int> P[509];
long double pas,ans,A,B,C,D,E,JM,dp[109][109][109];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>K;
	for(i=1; i<=a; i++){
		cin>>p[i].first.first>>p[i].first.second;ans+=p[i].first.first;p[i].second=i;
		if(p[i].first.second==-1) p[i].first.second=N;
	}
	for(i=1; i<=a; i++) swap(p[i].first.first,p[i].first.second);
	sort(p+1,p+a+1);
	for(i=1; i<=a; i++) swap(p[i].first.first,p[i].first.second);
	for(T=0; T<=K; T++){
		for(i=0; i<=a+1; i++){
			//for(j=0; j<=a+1-i; j++){
			for(j=0; j<=a+1; j++){
				for(ii=0; ii<=a+1; ii++){
					dp[ii][i][j]=500002.0;
				}
			}
		}
		dp[0][0][0]=0.0;
		for(ii=1; ii<=a; ii++){
			for(i=0; i<=ii; i++){
				if(i>K) break;
				for(j=0; j<=ii-i; j++){
					if(i+j>K||j>T) break;
					if(i+j<=ii-1){
						dp[ii][i][j]=min(dp[ii][i][j],dp[ii-1][i][j]);
					}
					if(i>0){
						A=p[ii].first.first;B=T+1;
						dp[ii][i][j]=min(dp[ii][i][j],dp[ii-1][i-1][j]+A/B);
					}
					if(j>0&&p[ii].first.second!=N){
						A=p[ii].first.second;B=j;
						dp[ii][i][j]=min(dp[ii][i][j],dp[ii-1][i][j-1]+A/B);
					}
				}
			}
		}
		//cout<<T<<" "<<dp[a][K-T][T]<<"\n";
		ans=min(ans,dp[a][K-T][T]);
	}
	cout<<setprecision(12)<<ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Runtime error 3 ms 1356 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Runtime error 3 ms 1356 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 0 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 0 ms 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 0 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 0 ms 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 1100 KB Output is correct
17 Correct 2 ms 1100 KB Output is correct
18 Correct 2 ms 1100 KB Output is correct
19 Correct 2 ms 1100 KB Output is correct
20 Correct 2 ms 1100 KB Output is correct
21 Correct 2 ms 1100 KB Output is correct
22 Correct 2 ms 1100 KB Output is correct
23 Correct 2 ms 1100 KB Output is correct
24 Correct 2 ms 1100 KB Output is correct
25 Correct 2 ms 1100 KB Output is correct
26 Correct 3 ms 1100 KB Output is correct
27 Correct 2 ms 1100 KB Output is correct
28 Correct 2 ms 1100 KB Output is correct
29 Correct 2 ms 1100 KB Output is correct
30 Correct 2 ms 1100 KB Output is correct
31 Correct 2 ms 1100 KB Output is correct
32 Correct 2 ms 1100 KB Output is correct
33 Correct 2 ms 1100 KB Output is correct
34 Correct 2 ms 1100 KB Output is correct
35 Correct 2 ms 1100 KB Output is correct
36 Correct 2 ms 1100 KB Output is correct
37 Correct 2 ms 1100 KB Output is correct
38 Correct 2 ms 1100 KB Output is correct
39 Correct 2 ms 1100 KB Output is correct
40 Correct 2 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 0 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 0 ms 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 1100 KB Output is correct
17 Correct 2 ms 1100 KB Output is correct
18 Correct 2 ms 1100 KB Output is correct
19 Correct 2 ms 1100 KB Output is correct
20 Correct 2 ms 1100 KB Output is correct
21 Correct 2 ms 1100 KB Output is correct
22 Correct 2 ms 1100 KB Output is correct
23 Correct 2 ms 1100 KB Output is correct
24 Correct 2 ms 1100 KB Output is correct
25 Correct 2 ms 1100 KB Output is correct
26 Correct 3 ms 1100 KB Output is correct
27 Correct 2 ms 1100 KB Output is correct
28 Correct 2 ms 1100 KB Output is correct
29 Correct 2 ms 1100 KB Output is correct
30 Correct 2 ms 1100 KB Output is correct
31 Correct 2 ms 1100 KB Output is correct
32 Correct 2 ms 1100 KB Output is correct
33 Correct 2 ms 1100 KB Output is correct
34 Correct 2 ms 1100 KB Output is correct
35 Correct 2 ms 1100 KB Output is correct
36 Correct 2 ms 1100 KB Output is correct
37 Correct 2 ms 1100 KB Output is correct
38 Correct 2 ms 1100 KB Output is correct
39 Correct 2 ms 1100 KB Output is correct
40 Correct 2 ms 1100 KB Output is correct
41 Correct 116 ms 18452 KB Output is correct
42 Correct 118 ms 18460 KB Output is correct
43 Correct 233 ms 18380 KB Output is correct
44 Correct 228 ms 18452 KB Output is correct
45 Correct 425 ms 18456 KB Output is correct
46 Correct 412 ms 18380 KB Output is correct
47 Correct 586 ms 18456 KB Output is correct
48 Correct 574 ms 18456 KB Output is correct
49 Correct 770 ms 18500 KB Output is correct
50 Correct 733 ms 18380 KB Output is correct
51 Correct 1033 ms 18380 KB Output is correct
52 Correct 1000 ms 18456 KB Output is correct
53 Correct 640 ms 18456 KB Output is correct
54 Correct 595 ms 18464 KB Output is correct
55 Correct 629 ms 18460 KB Output is correct
56 Correct 662 ms 18452 KB Output is correct
57 Correct 616 ms 18380 KB Output is correct
58 Correct 597 ms 18500 KB Output is correct
59 Correct 589 ms 18468 KB Output is correct
60 Correct 591 ms 18452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1356 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Runtime error 3 ms 1356 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -