제출 #1108402

#제출 시각아이디문제언어결과실행 시간메모리
1108402vjudge1Art Exhibition (JOI18_art)C++17
100 / 100
145 ms20040 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define FORD(i, b, a) for(int i = (b); i >= (a); i--) #define pa pair<ll, ll> #define fi first #define se second #define bit(mask, j) (mask & (1<<j)) const ll mod = 1e9 + 7; const ll INF = 1e17; const ll N = 5e5 + 10; pa a[N]; ll s[N], dmax[N], dd[N], ans = 0; int main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); #define NAME "hbmt" if(fopen(NAME".inp", "r")) { freopen(NAME".inp", "r", stdin); freopen(NAME".out", "w", stdout); } ll n; cin >> n; FOR(i, 1, n) { cin >> a[i].fi >> a[i].se; } sort(a + 1, a + n + 1); FORD(i, n, 1) { s[i] = s[i + 1] + a[i].se; dmax[i] = s[i] + a[i].fi; } FOR(i, 1, n) { dd[i] = max(dd[i - 1], dmax[i]); } FOR(i, 1, n) { ans = max(ans, dd[i] - a[i].fi - s[i + 1]); } cout << ans; return 0; }

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

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