제출 #1079238

#제출 시각아이디문제언어결과실행 시간메모리
1079238vjudge1Art Exhibition (JOI18_art)C++17
100 / 100
146 ms28756 KiB
#include <bits/stdc++.h> #define task "MAXNUM" #define pl pair<ll, ll> #define pf push_front #define pb push_back #define pob pop_back #define pof pop_front #define mp make_pair #define fi first #define se second #define FOR(i, a, b, c) for (int i=a; i<=b; i+=c) #define FORE(i, a, b, c) for (int i=a; i>=b; i+=c) #define VI vector <int> using namespace std; using ll = long long; using ull = unsigned long long; const int Mod = 123456789; const int maxn = 5e5+1; const ll Inf = 3e18; pl A[maxn+1]; ll B[maxn+2], C[maxn+2], sum2, sum, n, res; void Read() { cin >> n; FOR(i, 1, n, 1) { cin >> A[i].fi >> A[i].se; sum2 += A[i].se; } } void Solve() { B[0] = -Inf, C[n+1] = -Inf; sort (A + 1, A + n + 1); FOR(i, 1, n, 1) { B[i] = max(B[i-1], A[i].fi - sum); sum += A[i].se; } FORE(i, n, 1, -1) { C[i] = max(C[i+1], sum2 - A[i].fi); sum2 -= A[i].se; } //FOR(i, 1, n, 1) cout << B[i] << " " << C[i] << '\n'; FOR(i, 1, n, 1) { res = max(res, C[i] + B[i]); } cout << res; } int main() { if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; for (t=1; t--;) { Read(); Solve(); } }

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

art.cpp: In function 'int main()':
art.cpp:51:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:52:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         freopen (task".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...