제출 #775899

#제출 시각아이디문제언어결과실행 시간메모리
775899egekabasSure Bet (CEOI17_sure)C++14
100 / 100
73 ms5084 KiB
#include <bits/stdc++.h> #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define pb push_back using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ld, ld> pld; int n; ld a[100009], b[100009]; int main(){ // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); cin >> n; for(int i = 0; i < n; ++i){ scanf("%Lf", &a[i]); scanf("%Lf", &b[i]); } sort(a, a+n, greater<ld>()); sort(b, b+n, greater<ld>()); ld ans = 0; ld aProfit = 0; int aIndex = 0; ld bProfit = 0; int bIndex = 0; int spent = 0; while(aIndex < n || bIndex < n){ spent += 1; if(aIndex < n && (bIndex >= n || aProfit < bProfit)){ aProfit += a[aIndex++]; } else{ bProfit += b[bIndex++]; } ans = max(ans, min(aProfit, bProfit)-spent); } printf("%.4lf", (double)ans); }

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

sure.cpp: In function 'int main()':
sure.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("%Lf", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~~
sure.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         scanf("%Lf", &b[i]);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...