제출 #303028

#제출 시각아이디문제언어결과실행 시간메모리
303028Kenzo_1114Sure Bet (CEOI17_sure)C++14
0 / 100
1 ms256 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 100010; int n; double a[MAXN], b[MAXN], ans = (int) 0, sa = (int) 0, sb = (int) 0; int main () { scanf("%d", &n); for(int i = 0; i < n; i++) scanf("%lf %lf", &a[i], &b[i]); sort(a, a + n); reverse(a, a + n); sort(b, b + n); reverse(b, b + n); int ida = 0, idb = 0; for(int i = 0; i < n; i++) { if(sa >= sb && idb < n) sb += b[idb++]; else if(sa < sb && ida < n) sa += a[ida++]; ans = max(ans, min(sa, sb) - i - 1); } printf("%.4lf\n", ans); } /* 4 1.4 3.7 1.2 2 1.6 1.4 1.9 1.5 */

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

sure.cpp: In function 'int main()':
sure.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
sure.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |   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...