답안 #933337

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
933337 2024-02-25T14:03:14 Z koukirocks Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
12 ms 4496 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];

int main() {
	speed;
	cin>>n>>k;
	for (int i=1;i<=n;i++) {
		cin>>vt[i].first>>vt[i].second;
	}
	sort(vt+1,vt+n+1,[=](pair<ldb,ldb> a,pair<ldb,ldb> b){
		if (a.second==-1) a.second=oo;
		if (b.second==-1) b.second=oo;
		if (a.second==b.second) return a.first>b.first;
		return a.second<b.second;
	});
	for (int i=1;i<=k;i++) dp[0][i]=oo;
	dp[0][0]=0;
	for (int i=1;i<=n;i++) {
		dp[i][0]=0;
		for (int j=1;j<=k;j++) {
			if (vt[i].second==-1) dp[i][j]=dp[i-1][j];
			else dp[i][j]=min(dp[i-1][j-1]+vt[i].second/j,dp[i-1][j]);
//			cout<<dp[i][j]<<" ";
		}
//		cout<<"\n";
	}
	ldb ans=oo;
	for (int i=0;i<=n;i++) {
		vector<ldb> rest;
		for (int j=i+1;j<=n;j++) rest.push_back(vt[j].first);
		sort(all(rest));
		ldb ttl=0;
		for (int j=k;j>=0;j--) {
			ans=min(ans,dp[i][j]+ttl/(j+1));
//			cout<<i<<" "<<j<<" "<<dp[i][j]<<" "<<ttl<<"\n";
			if (k-j>=rest.size()) break;
			ttl+=rest[k-j];
		}
//		cout<<"\n";
	}
	cout<<fixed<<setprecision(20)<<ans<<"\n";
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:51:11: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |    if (k-j>=rest.size()) break;
      |        ~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 4 ms 3676 KB Output is correct
6 Correct 5 ms 3932 KB Output is correct
7 Correct 6 ms 4444 KB Output is correct
8 Correct 6 ms 4496 KB Output is correct
9 Correct 6 ms 4444 KB Output is correct
10 Correct 6 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 4 ms 3676 KB Output is correct
6 Correct 5 ms 3932 KB Output is correct
7 Correct 6 ms 4444 KB Output is correct
8 Correct 6 ms 4496 KB Output is correct
9 Correct 6 ms 4444 KB Output is correct
10 Correct 6 ms 4444 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 5 ms 3932 KB Output is correct
13 Correct 8 ms 4108 KB Output is correct
14 Correct 6 ms 3932 KB Output is correct
15 Correct 6 ms 4440 KB Output is correct
16 Correct 8 ms 4440 KB Output is correct
17 Correct 7 ms 4444 KB Output is correct
18 Correct 7 ms 4444 KB Output is correct
19 Correct 9 ms 4436 KB Output is correct
20 Correct 7 ms 4440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 4256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 4 ms 3676 KB Output is correct
6 Correct 5 ms 3932 KB Output is correct
7 Correct 6 ms 4444 KB Output is correct
8 Correct 6 ms 4496 KB Output is correct
9 Correct 6 ms 4444 KB Output is correct
10 Correct 6 ms 4444 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 5 ms 3932 KB Output is correct
13 Correct 8 ms 4108 KB Output is correct
14 Correct 6 ms 3932 KB Output is correct
15 Correct 6 ms 4440 KB Output is correct
16 Correct 8 ms 4440 KB Output is correct
17 Correct 7 ms 4444 KB Output is correct
18 Correct 7 ms 4444 KB Output is correct
19 Correct 9 ms 4436 KB Output is correct
20 Correct 7 ms 4440 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Incorrect 0 ms 348 KB Output isn't correct
30 Halted 0 ms 0 KB -