제출 #115062

#제출 시각아이디문제언어결과실행 시간메모리
115062IOrtroiiiSure Bet (CEOI17_sure)C++14
100 / 100
94 ms3812 KiB
#include <bits/stdc++.h>

using namespace std;

int main() {
   int n;
   scanf("%d", &n);
   priority_queue<double> qa;
   priority_queue<double> qb;
   for (int i = 1; i <= n; ++i) {
      double a, b;
      scanf("%lf %lf", &a, &b);
      qa.emplace(a);
      qb.emplace(b);
   }
   double sa = 0.0;
   double sb = 0.0;
   double ans = 0.0;
   for (int i = 1; i <= 2 * n; ++i) {
      if (sa < sb) {
         if (qa.empty()) break;
         sa += qa.top();
         qa.pop();
      } else {
         if (qb.empty()) break;
         sb += qb.top();
         qb.pop();
      }
      ans = max(ans, min(sa, sb) - 1.0 * i);
   }
   cout << fixed << setprecision(4) << ans << endl;
}

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

sure.cpp: In function 'int main()':
sure.cpp:7:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &n);
    ~~~~~^~~~~~~~~~
sure.cpp:12:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%lf %lf", &a, &b);
       ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...