| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 638728 | jamezzz | Let's Win the Election (JOI22_ho_t3) | C++17 | 513 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define sf scanf
#define pf printf
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
#define maxn 505
#define INF 1023456789
int n,k,a[maxn],b[maxn];
vector<ii> v;
ld memo[maxn];
int main(){
sf("%d%d",&n,&k);
for(int i=0;i<n;++i){
int x,y;
sf("%d%d",&x,&y);
if(y==-1)y=INF;
v.push_back({y,x});
}
sort(v.begin(),v.end());
int cnt=0;
for(int i=0;i<n;++i){
tie(b[i],a[i])=v[i];
if(b[i]!=INF)++cnt;
}
ld ans=INF;
for(int take=0;take<=min(k,cnt);++take){
for(int i=0;i<=n+1;++i){
memo[i]=INF;
}
memo[0]=0;
for(int pos=0;pos<n;++pos){
for(int vote=k-take;vote>=0;--vote){
ld ans=INF;
//case 1: take this
if(vote!=0)ans=min(ans,memo[vote-1]+(ld)a[pos]/(take+1));
//case 2: don't take this
//if this is one of the collaborators, add cost
if(pos-vote<take){
ans=min(ans,memo[vote]+(ld)b[pos]/(pos-vote+1));
}
else ans=min(ans,memo[vote]);
memo[vote]=ans;
}
}
ans=min(ans,memo[k-take]);
}
pf("%.15Lf\n",ans);
}
/*
7
5
393 646
375 666
374 676
320 635
288 668
284 758
333 702
1258.500000000000000
*/
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
