제출 #1265083

#제출 시각아이디문제언어결과실행 시간메모리
1265083ducdevArt Exhibition (JOI18_art)C++17
0 / 100
0 ms320 KiB
// Author: 4uckd3v - Nguyen Cao Duc #include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAX_N = 5e5; const int MOD = 1e9 + 7; int n; int comp[MAX_N + 5]; ll bit[MAX_N + 5]; pair<ll, int> a[MAX_N + 5]; void update(int pos, ll val) { for (; pos <= n; pos += pos & (-pos)) bit[pos] = min(bit[pos], val); }; ll get(int pos) { ll ret = 1e18; for (; pos > 0; pos -= pos & (-pos)) ret = min(ret, bit[pos]); return ret; }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); if (fopen("MAIN.INP", "r")) { freopen("MAIN.INP", "r", stdin); freopen("MAIN.OUT", "w", stdout); }; cin >> n; vector<pair<ll, int>> v(n); for (int i = 1; i <= n; i++) { cin >> a[i].first >> a[i].second; v[i - 1] = make_pair(a[i].first, i); bit[i] = 1e18; }; sort(v.begin(), v.end()); int cur = 0; for (int i = 0; i < n; i++) { cur += (i == 0 || v[i - 1].first != v[i].first); comp[v[i].second] = cur; }; sort(a + 1, a + n + 1); ll pref = 0, res = 0; for (int i = 1; i <= n; i++) { pref += a[i].second; res = max(res, (pref - a[i].first) - get(comp[i])); res = max(res, pref - a[i].first + a[1].first); update(comp[i], pref - a[i].second - a[i].first); }; cout << res << '\n'; };

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

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