제출 #530096

#제출 시각아이디문제언어결과실행 시간메모리
530096buidangnguyen05Art Exhibition (JOI18_art)C++14
0 / 100
1 ms332 KiB
/* input */ #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 5e5 + 10; ll pref[N], mx[N]; pair<ll, int> a[N]; signed main() { cin.tie(0)->sync_with_stdio(0); if (fopen("task.inp", "r")) { freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); } int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second; sort(a + 1, a + n + 1); for (int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + a[i].second; for (int i = n; i; --i) mx[i] = max(mx[i + 1], pref[i] - a[i].first); ll res = 0; for (int i = 1; i <= n; ++i) res = max(res, a[i].first - pref[i - 1] + mx[i]); cout << res << "\n"; }

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

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