답안 #1106229

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1106229 2024-10-29T15:23:03 Z akim9905 Let's Win the Election (JOI22_ho_t3) C++17
100 / 100
632 ms 2632 KB
#include <bits/stdc++.h>
using namespace std;

#define fileio() freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define fio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) (x).begin(), (x).end()
#define allr(x) x.rbegin(), x.rend()
#define cmprs(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define endl "\n"
#define sp " "
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define rz resize
#define sz(a) (int)(a.size())
#define clr(a) a.clear()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef tuple<int, int, int> tpi;
typedef tuple<ll, ll, ll> tpl;
typedef pair<double, ll> pdl;
typedef pair<double, int> pdi;

const int dx[] = {1,-1,0,0,1,1,-1,-1};
const int dy[] = {0,0,1,-1,1,-1,1,-1};
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MAX = 505; // PLZ CHK!

int N,K;
pair<double,double> A[MAX];
double D[MAX][MAX];
const double eps=1e-9;

double go(int i, int x, int h) {
    if (x==K-h && i-1-x>=h) return 0.0;
    if (i>N) return 1e9;

    double &ret=D[i][x];
    if (ret>-1.0) return ret;

    ret=1e9;
    if (x<K-h) ret=min(ret, A[i].first/(1.0*(1+h))+go(i+1,x+1,h));

    int y=i-1-x;
    double t=0.0;
    if (y<h) t=A[i].second/(1.0*(1+y));
    ret=min(ret, t+go(i+1,x,h));

    return ret;
}

int main() {
    fio();
    cin>>N>>K;
    for (int i=1; i<=N; i++) {
        cin>>A[i].first>>A[i].second;
        if (abs(A[i].second+1.0)<eps) A[i].second=1e6;
    }

    sort(A+1,A+N+1,[](auto a, auto b){
        return a.second<b.second;
    });

    double ans=1e9;
    for (int i=0; i<=K; i++) {
        fill_n(&D[0][0],MAX*MAX,-1.0);
        // cout<<go(1,0,i)<<endl;
        ans=min(ans, go(1,0,i));
    }

    cout<<fixed; cout.precision(10);
    cout<<ans;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 2 ms 2384 KB Output is correct
4 Correct 2 ms 2384 KB Output is correct
5 Correct 14 ms 2384 KB Output is correct
6 Correct 55 ms 2480 KB Output is correct
7 Correct 187 ms 2384 KB Output is correct
8 Correct 356 ms 2384 KB Output is correct
9 Correct 552 ms 2384 KB Output is correct
10 Correct 328 ms 2488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 2 ms 2384 KB Output is correct
4 Correct 2 ms 2384 KB Output is correct
5 Correct 14 ms 2384 KB Output is correct
6 Correct 55 ms 2480 KB Output is correct
7 Correct 187 ms 2384 KB Output is correct
8 Correct 356 ms 2384 KB Output is correct
9 Correct 552 ms 2384 KB Output is correct
10 Correct 328 ms 2488 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 83 ms 2384 KB Output is correct
13 Correct 79 ms 2384 KB Output is correct
14 Correct 81 ms 2384 KB Output is correct
15 Correct 325 ms 2384 KB Output is correct
16 Correct 322 ms 2552 KB Output is correct
17 Correct 318 ms 2484 KB Output is correct
18 Correct 542 ms 2384 KB Output is correct
19 Correct 555 ms 2480 KB Output is correct
20 Correct 574 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 2 ms 2384 KB Output is correct
3 Correct 2 ms 2384 KB Output is correct
4 Correct 2 ms 2384 KB Output is correct
5 Correct 2 ms 2384 KB Output is correct
6 Correct 2 ms 2384 KB Output is correct
7 Correct 2 ms 2384 KB Output is correct
8 Correct 4 ms 2384 KB Output is correct
9 Correct 3 ms 2384 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 3 ms 2400 KB Output is correct
13 Correct 3 ms 2384 KB Output is correct
14 Correct 2 ms 2384 KB Output is correct
15 Correct 4 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 2 ms 2384 KB Output is correct
3 Correct 2 ms 2384 KB Output is correct
4 Correct 2 ms 2384 KB Output is correct
5 Correct 2 ms 2384 KB Output is correct
6 Correct 2 ms 2384 KB Output is correct
7 Correct 2 ms 2384 KB Output is correct
8 Correct 4 ms 2384 KB Output is correct
9 Correct 3 ms 2384 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 3 ms 2400 KB Output is correct
13 Correct 3 ms 2384 KB Output is correct
14 Correct 2 ms 2384 KB Output is correct
15 Correct 4 ms 2384 KB Output is correct
16 Correct 2 ms 2384 KB Output is correct
17 Correct 3 ms 2384 KB Output is correct
18 Correct 3 ms 2384 KB Output is correct
19 Correct 3 ms 2456 KB Output is correct
20 Correct 3 ms 2384 KB Output is correct
21 Correct 3 ms 2384 KB Output is correct
22 Correct 4 ms 2384 KB Output is correct
23 Correct 4 ms 2384 KB Output is correct
24 Correct 3 ms 2256 KB Output is correct
25 Correct 6 ms 2384 KB Output is correct
26 Correct 6 ms 2384 KB Output is correct
27 Correct 3 ms 2384 KB Output is correct
28 Correct 4 ms 2392 KB Output is correct
29 Correct 3 ms 2556 KB Output is correct
30 Correct 3 ms 2384 KB Output is correct
31 Correct 3 ms 2552 KB Output is correct
32 Correct 4 ms 2384 KB Output is correct
33 Correct 3 ms 2384 KB Output is correct
34 Correct 4 ms 2304 KB Output is correct
35 Correct 4 ms 2384 KB Output is correct
36 Correct 3 ms 2384 KB Output is correct
37 Correct 4 ms 2384 KB Output is correct
38 Correct 3 ms 2384 KB Output is correct
39 Correct 4 ms 2384 KB Output is correct
40 Correct 3 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 2 ms 2384 KB Output is correct
3 Correct 2 ms 2384 KB Output is correct
4 Correct 2 ms 2384 KB Output is correct
5 Correct 2 ms 2384 KB Output is correct
6 Correct 2 ms 2384 KB Output is correct
7 Correct 2 ms 2384 KB Output is correct
8 Correct 4 ms 2384 KB Output is correct
9 Correct 3 ms 2384 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 3 ms 2400 KB Output is correct
13 Correct 3 ms 2384 KB Output is correct
14 Correct 2 ms 2384 KB Output is correct
15 Correct 4 ms 2384 KB Output is correct
16 Correct 2 ms 2384 KB Output is correct
17 Correct 3 ms 2384 KB Output is correct
18 Correct 3 ms 2384 KB Output is correct
19 Correct 3 ms 2456 KB Output is correct
20 Correct 3 ms 2384 KB Output is correct
21 Correct 3 ms 2384 KB Output is correct
22 Correct 4 ms 2384 KB Output is correct
23 Correct 4 ms 2384 KB Output is correct
24 Correct 3 ms 2256 KB Output is correct
25 Correct 6 ms 2384 KB Output is correct
26 Correct 6 ms 2384 KB Output is correct
27 Correct 3 ms 2384 KB Output is correct
28 Correct 4 ms 2392 KB Output is correct
29 Correct 3 ms 2556 KB Output is correct
30 Correct 3 ms 2384 KB Output is correct
31 Correct 3 ms 2552 KB Output is correct
32 Correct 4 ms 2384 KB Output is correct
33 Correct 3 ms 2384 KB Output is correct
34 Correct 4 ms 2304 KB Output is correct
35 Correct 4 ms 2384 KB Output is correct
36 Correct 3 ms 2384 KB Output is correct
37 Correct 4 ms 2384 KB Output is correct
38 Correct 3 ms 2384 KB Output is correct
39 Correct 4 ms 2384 KB Output is correct
40 Correct 3 ms 2384 KB Output is correct
41 Correct 4 ms 2384 KB Output is correct
42 Correct 4 ms 2384 KB Output is correct
43 Correct 5 ms 2384 KB Output is correct
44 Correct 5 ms 2384 KB Output is correct
45 Correct 8 ms 2460 KB Output is correct
46 Correct 8 ms 2384 KB Output is correct
47 Correct 9 ms 2464 KB Output is correct
48 Correct 10 ms 2552 KB Output is correct
49 Correct 12 ms 2384 KB Output is correct
50 Correct 12 ms 2460 KB Output is correct
51 Correct 15 ms 2384 KB Output is correct
52 Correct 15 ms 2384 KB Output is correct
53 Correct 10 ms 2396 KB Output is correct
54 Correct 9 ms 2384 KB Output is correct
55 Correct 9 ms 2384 KB Output is correct
56 Correct 10 ms 2436 KB Output is correct
57 Correct 9 ms 2384 KB Output is correct
58 Correct 10 ms 2384 KB Output is correct
59 Correct 10 ms 2464 KB Output is correct
60 Correct 10 ms 2460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 548 ms 2632 KB Output is correct
2 Correct 561 ms 2384 KB Output is correct
3 Correct 553 ms 2384 KB Output is correct
4 Correct 561 ms 2384 KB Output is correct
5 Correct 557 ms 2384 KB Output is correct
6 Correct 632 ms 2488 KB Output is correct
7 Correct 549 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 2 ms 2384 KB Output is correct
4 Correct 2 ms 2384 KB Output is correct
5 Correct 14 ms 2384 KB Output is correct
6 Correct 55 ms 2480 KB Output is correct
7 Correct 187 ms 2384 KB Output is correct
8 Correct 356 ms 2384 KB Output is correct
9 Correct 552 ms 2384 KB Output is correct
10 Correct 328 ms 2488 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 83 ms 2384 KB Output is correct
13 Correct 79 ms 2384 KB Output is correct
14 Correct 81 ms 2384 KB Output is correct
15 Correct 325 ms 2384 KB Output is correct
16 Correct 322 ms 2552 KB Output is correct
17 Correct 318 ms 2484 KB Output is correct
18 Correct 542 ms 2384 KB Output is correct
19 Correct 555 ms 2480 KB Output is correct
20 Correct 574 ms 2384 KB Output is correct
21 Correct 2 ms 2384 KB Output is correct
22 Correct 2 ms 2384 KB Output is correct
23 Correct 2 ms 2384 KB Output is correct
24 Correct 2 ms 2384 KB Output is correct
25 Correct 2 ms 2384 KB Output is correct
26 Correct 2 ms 2384 KB Output is correct
27 Correct 2 ms 2384 KB Output is correct
28 Correct 4 ms 2384 KB Output is correct
29 Correct 3 ms 2384 KB Output is correct
30 Correct 2 ms 2384 KB Output is correct
31 Correct 2 ms 2384 KB Output is correct
32 Correct 3 ms 2400 KB Output is correct
33 Correct 3 ms 2384 KB Output is correct
34 Correct 2 ms 2384 KB Output is correct
35 Correct 4 ms 2384 KB Output is correct
36 Correct 2 ms 2384 KB Output is correct
37 Correct 3 ms 2384 KB Output is correct
38 Correct 3 ms 2384 KB Output is correct
39 Correct 3 ms 2456 KB Output is correct
40 Correct 3 ms 2384 KB Output is correct
41 Correct 3 ms 2384 KB Output is correct
42 Correct 4 ms 2384 KB Output is correct
43 Correct 4 ms 2384 KB Output is correct
44 Correct 3 ms 2256 KB Output is correct
45 Correct 6 ms 2384 KB Output is correct
46 Correct 6 ms 2384 KB Output is correct
47 Correct 3 ms 2384 KB Output is correct
48 Correct 4 ms 2392 KB Output is correct
49 Correct 3 ms 2556 KB Output is correct
50 Correct 3 ms 2384 KB Output is correct
51 Correct 3 ms 2552 KB Output is correct
52 Correct 4 ms 2384 KB Output is correct
53 Correct 3 ms 2384 KB Output is correct
54 Correct 4 ms 2304 KB Output is correct
55 Correct 4 ms 2384 KB Output is correct
56 Correct 3 ms 2384 KB Output is correct
57 Correct 4 ms 2384 KB Output is correct
58 Correct 3 ms 2384 KB Output is correct
59 Correct 4 ms 2384 KB Output is correct
60 Correct 3 ms 2384 KB Output is correct
61 Correct 4 ms 2384 KB Output is correct
62 Correct 4 ms 2384 KB Output is correct
63 Correct 5 ms 2384 KB Output is correct
64 Correct 5 ms 2384 KB Output is correct
65 Correct 8 ms 2460 KB Output is correct
66 Correct 8 ms 2384 KB Output is correct
67 Correct 9 ms 2464 KB Output is correct
68 Correct 10 ms 2552 KB Output is correct
69 Correct 12 ms 2384 KB Output is correct
70 Correct 12 ms 2460 KB Output is correct
71 Correct 15 ms 2384 KB Output is correct
72 Correct 15 ms 2384 KB Output is correct
73 Correct 10 ms 2396 KB Output is correct
74 Correct 9 ms 2384 KB Output is correct
75 Correct 9 ms 2384 KB Output is correct
76 Correct 10 ms 2436 KB Output is correct
77 Correct 9 ms 2384 KB Output is correct
78 Correct 10 ms 2384 KB Output is correct
79 Correct 10 ms 2464 KB Output is correct
80 Correct 10 ms 2460 KB Output is correct
81 Correct 548 ms 2632 KB Output is correct
82 Correct 561 ms 2384 KB Output is correct
83 Correct 553 ms 2384 KB Output is correct
84 Correct 561 ms 2384 KB Output is correct
85 Correct 557 ms 2384 KB Output is correct
86 Correct 632 ms 2488 KB Output is correct
87 Correct 549 ms 2384 KB Output is correct
88 Correct 14 ms 2384 KB Output is correct
89 Correct 14 ms 2384 KB Output is correct
90 Correct 58 ms 2384 KB Output is correct
91 Correct 64 ms 2552 KB Output is correct
92 Correct 186 ms 2384 KB Output is correct
93 Correct 185 ms 2384 KB Output is correct
94 Correct 362 ms 2556 KB Output is correct
95 Correct 356 ms 2384 KB Output is correct
96 Correct 505 ms 2384 KB Output is correct
97 Correct 474 ms 2552 KB Output is correct
98 Correct 320 ms 2260 KB Output is correct
99 Correct 324 ms 2252 KB Output is correct
100 Correct 327 ms 2384 KB Output is correct
101 Correct 319 ms 2384 KB Output is correct
102 Correct 330 ms 2384 KB Output is correct
103 Correct 316 ms 2384 KB Output is correct
104 Correct 321 ms 2384 KB Output is correct
105 Correct 324 ms 2488 KB Output is correct