Submission #551150

# Submission time Handle Problem Language Result Execution time Memory
551150 2022-04-19T23:24:23 Z DanerZein Let's Win the Election (JOI22_ho_t3) C++14
56 / 100
378 ms 21548 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<double,double> dd;
const int MAX=1e9;
bool orden(dd a,dd b){
  if(a.second==b.second) return a.first<b.first;
  return a.second<b.second;
}
int n;
vector<dd> st;
double ka;
double dp[110][110][110];
double knap(int id,int k,int ca){
  if(dp[id][k][ca]!=-1) return dp[id][k][ca];
  if(id==n) {
    if(ca==0 && k==ka) return 0;
    return MAX;
  }
  double ans=knap(id+1,k,ca);
  if(ca!=0){
    ans=min(ans,knap(id+1,k,ca-1)+st[id].first/(ka+1));
    if(k!=ka)
      ans=min(ans,knap(id+1,k+1,ca-1)+st[id].second/(double)(k+1));
  }
  return dp[id][k][ca]=ans;
}
int main(){
  int k; scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++){
    int a,b; scanf("%d%d",&a,&b);
    if(b==-1) b=MAX;
    st.push_back(dd(a,b));
  }
  sort(st.begin(),st.end(),orden);
  double res=MAX;
  for(int i=0;i<k;i++){
    ka=i;
    for(int id=0;id<=n;id++) for(int kk=0;kk<=n;kk++) for(int ca=0;ca<=n;ca++) dp[id][kk][ca]=-1;
    double rp=knap(0,0,k);
    //cout<<i<<": "<<rp<<endl;
    res=min(res,rp);
  }
  printf("%.15f\n",res);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:29:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   int k; scanf("%d%d",&n,&k);
      |          ~~~~~^~~~~~~~~~~~~~
Main.cpp:31:19: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     int a,b; scanf("%d%d",&a,&b);
      |              ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Runtime error 29 ms 21496 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Runtime error 29 ms 21496 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 0 ms 308 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 0 ms 308 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 724 KB Output is correct
17 Correct 1 ms 724 KB Output is correct
18 Correct 1 ms 692 KB Output is correct
19 Correct 1 ms 700 KB Output is correct
20 Correct 1 ms 696 KB Output is correct
21 Correct 1 ms 724 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 688 KB Output is correct
25 Correct 1 ms 724 KB Output is correct
26 Correct 1 ms 724 KB Output is correct
27 Correct 1 ms 724 KB Output is correct
28 Correct 1 ms 724 KB Output is correct
29 Correct 1 ms 724 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 1 ms 724 KB Output is correct
32 Correct 1 ms 724 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 2 ms 724 KB Output is correct
35 Correct 1 ms 724 KB Output is correct
36 Correct 1 ms 724 KB Output is correct
37 Correct 1 ms 700 KB Output is correct
38 Correct 1 ms 724 KB Output is correct
39 Correct 1 ms 724 KB Output is correct
40 Correct 1 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 0 ms 308 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 724 KB Output is correct
17 Correct 1 ms 724 KB Output is correct
18 Correct 1 ms 692 KB Output is correct
19 Correct 1 ms 700 KB Output is correct
20 Correct 1 ms 696 KB Output is correct
21 Correct 1 ms 724 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 688 KB Output is correct
25 Correct 1 ms 724 KB Output is correct
26 Correct 1 ms 724 KB Output is correct
27 Correct 1 ms 724 KB Output is correct
28 Correct 1 ms 724 KB Output is correct
29 Correct 1 ms 724 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 1 ms 724 KB Output is correct
32 Correct 1 ms 724 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 2 ms 724 KB Output is correct
35 Correct 1 ms 724 KB Output is correct
36 Correct 1 ms 724 KB Output is correct
37 Correct 1 ms 700 KB Output is correct
38 Correct 1 ms 724 KB Output is correct
39 Correct 1 ms 724 KB Output is correct
40 Correct 1 ms 724 KB Output is correct
41 Correct 20 ms 9428 KB Output is correct
42 Correct 18 ms 9396 KB Output is correct
43 Correct 47 ms 9428 KB Output is correct
44 Correct 46 ms 9476 KB Output is correct
45 Correct 107 ms 9428 KB Output is correct
46 Correct 100 ms 9428 KB Output is correct
47 Correct 166 ms 9480 KB Output is correct
48 Correct 224 ms 9480 KB Output is correct
49 Correct 242 ms 9476 KB Output is correct
50 Correct 256 ms 9476 KB Output is correct
51 Correct 344 ms 9472 KB Output is correct
52 Correct 378 ms 9428 KB Output is correct
53 Correct 162 ms 9488 KB Output is correct
54 Correct 236 ms 9476 KB Output is correct
55 Correct 192 ms 9480 KB Output is correct
56 Correct 156 ms 9480 KB Output is correct
57 Correct 200 ms 9476 KB Output is correct
58 Correct 197 ms 9480 KB Output is correct
59 Correct 162 ms 9476 KB Output is correct
60 Correct 165 ms 9472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 21548 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Runtime error 29 ms 21496 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -