Submission #824388

#TimeUsernameProblemLanguageResultExecution timeMemory
824388AmylopectinLet's Win the Election (JOI22_ho_t3)C++14
10 / 100
2 ms340 KiB
#include <stdio.h> #include <iostream> #include <algorithm> using namespace std; const int mxn = 2010; struct we { double aa,bb; int idx; }; bool cmp1(const struct we &l,const struct we &r) { return l.aa < r.aa; } bool cmp2(const struct we &l,const struct we &r) { if(l.bb == -1) { return false; } if(r.bb == -1) { return true; } if(l.bb == r.bb) { return l.aa > r.aa; } return l.bb < r.bb; } struct we soa[mxn] = {},sob[mxn] = {}; int u[mxn] = {}; int main() { int i,j,n,m,cn,cm,fn,fm,cou; double cva,cmi,f,p; scanf("%d %d",&n,&m); for(i=0; i<n; i++) { scanf("%lf %lf",&soa[i].aa,&soa[i].bb); soa[i].idx = i; sob[i] = {soa[i].aa,soa[i].bb,i}; } sort(soa,soa+n,cmp1); sort(sob,sob+n,cmp2); for(i=0; i<n; i++) { if(i > 0 && sob[i-1].bb == -1) { break; } cva = 0; for(j=0; j<i; j++) { u[sob[j].idx] = 1; f = j + 1; cva += sob[j].bb / f; } f = i+1; cou = i; for(j=0; j<n; j++) { if(u[soa[j].idx] == 0) { cou ++; cva += soa[j].aa / f; } if(cou == m) { break; } } if(i == 0) { cmi = cva; } else { cmi = min(cmi,cva); } } printf("%lf\n",cmi); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:35:17: warning: unused variable 'cn' [-Wunused-variable]
   35 |     int i,j,n,m,cn,cm,fn,fm,cou;
      |                 ^~
Main.cpp:35:20: warning: unused variable 'cm' [-Wunused-variable]
   35 |     int i,j,n,m,cn,cm,fn,fm,cou;
      |                    ^~
Main.cpp:35:23: warning: unused variable 'fn' [-Wunused-variable]
   35 |     int i,j,n,m,cn,cm,fn,fm,cou;
      |                       ^~
Main.cpp:35:26: warning: unused variable 'fm' [-Wunused-variable]
   35 |     int i,j,n,m,cn,cm,fn,fm,cou;
      |                          ^~
Main.cpp:36:22: warning: unused variable 'p' [-Wunused-variable]
   36 |     double cva,cmi,f,p;
      |                      ^
Main.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
Main.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         scanf("%lf %lf",&soa[i].aa,&soa[i].bb);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...