답안 #939857

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
939857 2024-03-06T20:31:22 Z Maite_Morale Let's Win the Election (JOI22_ho_t3) C++14
100 / 100
2478 ms 4260 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define MAX 505
#define oo 1e9+7
#define mod 1000000007
#define fast_in ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(3);
using namespace std;
typedef long long ll;
typedef long double db;
#define pll pair<ll , ll>
#define vll vector<ll>
#define vvll vector<vll>
#define vpll vector<pll>
 
ll t,n,m;
db dp[MAX][MAX];
pair<db,db> a[MAX];
int main(){
    fast_in
    cin>>n>>m;t=n;
    for(int i=0;i<n;i++){
        cin>>a[i].S>>a[i].F;
        if(a[i].F==-1){a[i].F=oo;t--;}
    }
    sort(a,a+n);
    db r=oo;
    for(int k=0;k<=min(t,m);k++){
        for(int j=0;j<=k;j++){
            for(int i=0;i+k<=m;i++){
                dp[i][j]=oo;
                if(i+j==0)dp[i][j]=0;
                if(i>0 )dp[i][j]=min(dp[i][j],dp[i-1][j]+a[i+j-1].S/(k+1));
                if(j>0)dp[i][j]=min(dp[i][j],dp[i][j-1]+a[i+j-1].F/j);
                if(k==j){
                   // cout<<i<<" "<<j<<"  "<<dp[i][j]<<" ";
                    priority_queue<db> q;
                    for(int h=i+k;h<n;h++){
                        q.push(-a[h].S);
                    }db ans=0;
                    for(int h=i+k;h<m;h++){
                        ans+=-q.top()/(k+1);q.pop();
                    }r=min(r,dp[i][k]+ans);//cout<<ans<<"\n";
                }
            }
        }
    }
    cout<<r;
return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 3 ms 2396 KB Output is correct
7 Correct 5 ms 2396 KB Output is correct
8 Correct 8 ms 2908 KB Output is correct
9 Correct 14 ms 3416 KB Output is correct
10 Correct 5 ms 2904 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 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 3 ms 2396 KB Output is correct
7 Correct 5 ms 2396 KB Output is correct
8 Correct 8 ms 2908 KB Output is correct
9 Correct 14 ms 3416 KB Output is correct
10 Correct 5 ms 2904 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 102 ms 2640 KB Output is correct
13 Correct 101 ms 2640 KB Output is correct
14 Correct 94 ms 2636 KB Output is correct
15 Correct 886 ms 2912 KB Output is correct
16 Correct 893 ms 3156 KB Output is correct
17 Correct 491 ms 2980 KB Output is correct
18 Correct 2063 ms 3916 KB Output is correct
19 Correct 1833 ms 4260 KB Output is correct
20 Correct 854 ms 3924 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 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 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 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 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 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 0 ms 472 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 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 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 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 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 0 ms 472 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 2 ms 2396 KB Output is correct
44 Correct 2 ms 2396 KB Output is correct
45 Correct 5 ms 2396 KB Output is correct
46 Correct 4 ms 2620 KB Output is correct
47 Correct 7 ms 2632 KB Output is correct
48 Correct 7 ms 2396 KB Output is correct
49 Correct 10 ms 2624 KB Output is correct
50 Correct 11 ms 2396 KB Output is correct
51 Correct 15 ms 2396 KB Output is correct
52 Correct 14 ms 2396 KB Output is correct
53 Correct 7 ms 2616 KB Output is correct
54 Correct 7 ms 2396 KB Output is correct
55 Correct 8 ms 2628 KB Output is correct
56 Correct 7 ms 2396 KB Output is correct
57 Correct 7 ms 2396 KB Output is correct
58 Correct 6 ms 2624 KB Output is correct
59 Correct 6 ms 2396 KB Output is correct
60 Correct 5 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2478 ms 3988 KB Output is correct
2 Correct 2449 ms 3760 KB Output is correct
3 Correct 2407 ms 4244 KB Output is correct
4 Correct 2419 ms 3964 KB Output is correct
5 Correct 2411 ms 4212 KB Output is correct
6 Correct 2474 ms 4100 KB Output is correct
7 Correct 2188 ms 3972 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 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 3 ms 2396 KB Output is correct
7 Correct 5 ms 2396 KB Output is correct
8 Correct 8 ms 2908 KB Output is correct
9 Correct 14 ms 3416 KB Output is correct
10 Correct 5 ms 2904 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 102 ms 2640 KB Output is correct
13 Correct 101 ms 2640 KB Output is correct
14 Correct 94 ms 2636 KB Output is correct
15 Correct 886 ms 2912 KB Output is correct
16 Correct 893 ms 3156 KB Output is correct
17 Correct 491 ms 2980 KB Output is correct
18 Correct 2063 ms 3916 KB Output is correct
19 Correct 1833 ms 4260 KB Output is correct
20 Correct 854 ms 3924 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 344 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 344 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 344 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 1 ms 348 KB Output is correct
56 Correct 0 ms 348 KB Output is correct
57 Correct 0 ms 344 KB Output is correct
58 Correct 0 ms 472 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 1 ms 344 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 2 ms 2396 KB Output is correct
64 Correct 2 ms 2396 KB Output is correct
65 Correct 5 ms 2396 KB Output is correct
66 Correct 4 ms 2620 KB Output is correct
67 Correct 7 ms 2632 KB Output is correct
68 Correct 7 ms 2396 KB Output is correct
69 Correct 10 ms 2624 KB Output is correct
70 Correct 11 ms 2396 KB Output is correct
71 Correct 15 ms 2396 KB Output is correct
72 Correct 14 ms 2396 KB Output is correct
73 Correct 7 ms 2616 KB Output is correct
74 Correct 7 ms 2396 KB Output is correct
75 Correct 8 ms 2628 KB Output is correct
76 Correct 7 ms 2396 KB Output is correct
77 Correct 7 ms 2396 KB Output is correct
78 Correct 6 ms 2624 KB Output is correct
79 Correct 6 ms 2396 KB Output is correct
80 Correct 5 ms 2396 KB Output is correct
81 Correct 2478 ms 3988 KB Output is correct
82 Correct 2449 ms 3760 KB Output is correct
83 Correct 2407 ms 4244 KB Output is correct
84 Correct 2419 ms 3964 KB Output is correct
85 Correct 2411 ms 4212 KB Output is correct
86 Correct 2474 ms 4100 KB Output is correct
87 Correct 2188 ms 3972 KB Output is correct
88 Correct 18 ms 2648 KB Output is correct
89 Correct 17 ms 2652 KB Output is correct
90 Correct 117 ms 2644 KB Output is correct
91 Correct 118 ms 2640 KB Output is correct
92 Correct 568 ms 2652 KB Output is correct
93 Correct 540 ms 2648 KB Output is correct
94 Correct 1426 ms 3304 KB Output is correct
95 Correct 1352 ms 3316 KB Output is correct
96 Correct 2078 ms 3412 KB Output is correct
97 Correct 2059 ms 3548 KB Output is correct
98 Correct 1240 ms 2964 KB Output is correct
99 Correct 1218 ms 2960 KB Output is correct
100 Correct 1225 ms 3728 KB Output is correct
101 Correct 1070 ms 2960 KB Output is correct
102 Correct 1010 ms 2960 KB Output is correct
103 Correct 969 ms 2904 KB Output is correct
104 Correct 955 ms 3144 KB Output is correct
105 Correct 557 ms 3160 KB Output is correct