답안 #933852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
933852 2024-02-26T12:11:02 Z koukirocks Let's Win the Election (JOI22_ho_t3) C++17
21 / 100
462 ms 8784 KB
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MAX=5e2+10,P=998244353;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;
 
ll n,k;
pair<ldb,ldb> vt[MAX];
ldb dp[MAX][MAX];
ldb suf[MAX][MAX];

int main() {
	speed;
	cin>>n>>k;
	for (int i=1;i<=n;i++) {
		cin>>vt[i].first>>vt[i].second;
		if (vt[i].second==-1) vt[i].second=oo;
	}
	sort(vt+1,vt+n+1,[=](pair<ldb,ldb> a,pair<ldb,ldb> b){
		if (abs(a.second-b.second)<1e-6) return a.first>b.first;
		return a.second<b.second;
	});
	for (int i=1;i<=k;i++) {
		suf[n+1][i]=oo;
	}
	suf[n+1][0]=0;
	for (int i=n;i>=1;i--) {
		suf[i][0]=0;
		for (int j=k;j>=1;j--) {
			suf[i][j]=min(suf[i+1][j-1]+vt[i].first,suf[i+1][j]);
//			cout<<i<<" "<<j<<" "<<suf[i][j]<<" suf\n";
		}
	}
	ldb ans=suf[1][k];
	for (int i=1;i<=k;i++) {
		for (int j=1;j<=n;j++) dp[0][j]=oo;
		dp[0][0]=0;
		for (int j=1;j<=k;j++) {
			for (int x=1;x<=n;x++) dp[j][x]=oo;
			dp[j][0]=dp[j-1][0]+vt[i].first/(i+1);
			for (int x=1;x<=i and x<=j;x++) {
				dp[j][x]=min(dp[j-1][x]+vt[j].first/(i+1),dp[j-1][x-1]+vt[j].second/x);
//				cout<<i<<" "<<j<<" "<<x<<" "<<dp[j-1][x]+vt[j].first/(i+1)<<" "<<dp[j-1][x-1]+vt[j].second/x<<"\n";
				if (x==i) {
					ans=min(ans,dp[j][x]+suf[j+1][k-j]/(i+1));
//					cout<<i<<" "<<j<<" "<<x<<" "<<dp[j][x]<<" "<<suf[j+1][k-j]/(i+1)<<"\n";
				}
			}
		}
	}
	cout<<fixed<<setprecision(20)<<ans<<"\n";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2508 KB Output is correct
5 Correct 3 ms 6492 KB Output is correct
6 Correct 18 ms 6740 KB Output is correct
7 Correct 80 ms 6800 KB Output is correct
8 Correct 222 ms 7540 KB Output is correct
9 Correct 426 ms 8784 KB Output is correct
10 Correct 176 ms 7256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2508 KB Output is correct
5 Correct 3 ms 6492 KB Output is correct
6 Correct 18 ms 6740 KB Output is correct
7 Correct 80 ms 6800 KB Output is correct
8 Correct 222 ms 7540 KB Output is correct
9 Correct 426 ms 8784 KB Output is correct
10 Correct 176 ms 7256 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 26 ms 6492 KB Output is correct
13 Correct 26 ms 6488 KB Output is correct
14 Correct 26 ms 6492 KB Output is correct
15 Correct 180 ms 7256 KB Output is correct
16 Correct 176 ms 7256 KB Output is correct
17 Correct 181 ms 7336 KB Output is correct
18 Correct 426 ms 8540 KB Output is correct
19 Correct 428 ms 8540 KB Output is correct
20 Correct 425 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Incorrect 1 ms 2396 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Incorrect 1 ms 2396 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Incorrect 1 ms 2396 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 442 ms 8540 KB Output is correct
2 Correct 458 ms 8784 KB Output is correct
3 Correct 462 ms 8784 KB Output is correct
4 Correct 430 ms 8540 KB Output is correct
5 Correct 440 ms 8536 KB Output is correct
6 Correct 455 ms 8536 KB Output is correct
7 Correct 435 ms 8536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2508 KB Output is correct
5 Correct 3 ms 6492 KB Output is correct
6 Correct 18 ms 6740 KB Output is correct
7 Correct 80 ms 6800 KB Output is correct
8 Correct 222 ms 7540 KB Output is correct
9 Correct 426 ms 8784 KB Output is correct
10 Correct 176 ms 7256 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 26 ms 6492 KB Output is correct
13 Correct 26 ms 6488 KB Output is correct
14 Correct 26 ms 6492 KB Output is correct
15 Correct 180 ms 7256 KB Output is correct
16 Correct 176 ms 7256 KB Output is correct
17 Correct 181 ms 7336 KB Output is correct
18 Correct 426 ms 8540 KB Output is correct
19 Correct 428 ms 8540 KB Output is correct
20 Correct 425 ms 8540 KB Output is correct
21 Correct 1 ms 2648 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Incorrect 1 ms 2396 KB Output isn't correct
34 Halted 0 ms 0 KB -