| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 528032 | amukkalir | Let's Win the Election (JOI22_ho_t3) | C++17 | 2037 ms | 496400 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define prn printf
#define scn scanf
#define pii pair<int,int>
#define fi first
#define se second
const int nax = 500;
const int inf = 1e9;
int n,k;
double memo[nax+5][nax+5][nax+5];
pii a[nax+5];
double dp(int idx, int col, int rem) {
if(rem == 0) return 0;
if(idx == n) return inf;
double &ret = memo[idx][col][rem];
if(ret!=0) return ret;
ret = dp(idx+1, col, rem); // ga ambil
ret = min(ret, (double)a[idx].se/col + dp(idx+1,col,rem-1));
if(a[idx].fi != inf) ret = min(ret, (double)a[idx].fi/col + dp(idx+1, col+1, rem-1));
// cerr << idx << " " << col << " " << rem << " = " << ret << endl;
return ret;
}
signed main () {
scn("%d%d", &n, &k);
for(int i=0; i<n; i++) {
scn("%d%d", &a[i].se, &a[i].fi);
if(a[i].fi == -1) a[i].fi = inf;
}
sort(a, a+n);
double ans = dp(0, 1, k);
prn("%f", ans);
}
/*
dp(i,j,k) = time minimum untuk visit k kota up to index i
ddn j collaboratior
dp(i,j,0) = 0
ambil b
dp(i+1, j+1, k-1) + b[i]
ambil a
dp(i+1, j, k-1) + a[i]
ga ambil
dp(i+1, j+1, k)
*/컴파일 시 표준 에러 (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... | ||||
