제출 #1257423

#제출 시각아이디문제언어결과실행 시간메모리
1257423Mike_VuSure Bet (CEOI17_sure)C++17
100 / 100
44 ms2224 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double dou; #define pii pair<int, int> #define fi first #define se second #define pb push_back #define BITJ(x, j) (((x)>>(j))&1) #define MASK(j) (1LL<<(j)) #define ALL(v) v.begin(), v.end() template<typename T> bool maximize(T &x, const T &y) { if (x < y) {x = y; return 1;} return 0; } template<typename T> bool minimize(T &x, const T &y) { if (x > y) {x = y; return 1;} return 0; } const int maxn = 1e5+5; int n; vector<dou> a, b; dou ans = 0; void solve() { int j = 0; dou s1 = 0, s2 = 0; for (int i = 0; i < n; i++) { s1 += a[i]; while (j < n && b[j]+s2 <= s1) { s2 += b[j]; ++j; } maximize(ans, min(s1, s2)-(i+1+j)); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); #define name "sure" if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } cin >> n; for (int i= 1; i <= n; i++) { dou x, y; cin >> x >> y; a.pb(x); b.pb(y); } sort(ALL(a), greater<dou>()); sort(ALL(b), greater<dou>()); solve(); //swap swap(a, b); solve(); cout << fixed<<setprecision(4)<<ans; }

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

sure.cpp: In function 'int main()':
sure.cpp:46:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:47:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...