| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 824355 | PoonYaPat | Let's Win the Election (JOI22_ho_t3) | C++14 | 2566 ms | 4324 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef pair<ld,ld> pii;
int n,k;
ld ans=1e9,a[505],b[505],dp[505][505];
vector<pii> v;
void check(ld want) {
for (int i=0; i<=n; ++i) for (int j=0; j<=n; ++j) dp[i][j]=1e9;
dp[0][0]=0;
for (int i=0; i<=k; ++i) {
if (i) {
for (int j=0; j<=want; ++j) {
if (j!=0 && b[i]!=1e9) dp[i][j]=min(dp[i][j],dp[i-1][j-1]+b[i]/j); //choose B
if (j!=want) dp[i][j]=min(dp[i][j],dp[i-1][j]+a[i]/(want+1)); //choose A
}
}
ld sum=0;
priority_queue<ld> q;
for (int j=i+1; j<=n; ++j) {
q.push(a[j]);
sum+=a[j];
if (q.size()>k-i) {
sum-=q.top();
q.pop();
}
}
if (dp[i][(int)(want)]<1000000) ans=min(ans,dp[i][(int)(want)]+sum/(want+1));
}
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n>>k;
for (int i=0; i<n; ++i) {
ld a,b; cin>>a>>b;
if (b!=-1) v.push_back(pii(b,a));
else v.push_back(pii(1e9,a));
}
sort(v.begin(),v.end());
for (int i=1; i<=n; ++i) a[i]=v[i-1].second, b[i]=v[i-1].first;
for (int i=0; i<=k; ++i) check(i);
cout<<setprecision(15)<<ans;
}컴파일 시 표준 에러 (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... | ||||
