제출 #61715

#제출 시각아이디문제언어결과실행 시간메모리
61715IvanCSure Bet (CEOI17_sure)C++17
100 / 100
134 ms16848 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; double A[MAXN],B[MAXN],pref_A[MAXN],pref_B[MAXN]; int N; double calcula(int x,int y){ return min(pref_A[x],pref_B[y]) - (x + y); } bool compara(double a,double b){ return a > b; } int main(){ double ans = 0.0; scanf("%d",&N); for(int i = 1;i<=N;i++){ scanf("%lf %lf",&A[i],&B[i]); } sort(A+1,A+N+1,compara); sort(B+1,B+N+1,compara); for(int i = 1;i<=N;i++){ pref_A[i] = pref_A[i-1] + A[i]; pref_B[i] = pref_B[i-1] + B[i]; } int opt = 0; for(int a = 0;a<=N;a++){ while(opt + 1 <= N && calcula(a,opt) < calcula(a,opt+1)){ opt++; } ans = max(ans,calcula(a,opt)); } printf("%.4lf\n",ans); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

sure.cpp: In function 'int main()':
sure.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&N);
  ~~~~~^~~~~~~~~
sure.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lf %lf",&A[i],&B[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...