제출 #1147327

#제출 시각아이디문제언어결과실행 시간메모리
1147327SangArt Exhibition (JOI18_art)C++20
100 / 100
127 ms12112 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++) #define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; i--) #define fi first #define se second #define pb push_back #define ALL(a) (a).begin(), (a).end() #define task "kbsiudthw" typedef vector<int> vi; typedef pair<int, int> ii; typedef pair<int, ii> pii; const int N = 5e5 + 5; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 2277; int n, pref[N]; ii a[N]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } cin >> n; FOR (i, 1, n) cin >> a[i].fi >> a[i].se; sort(a+1, a+n+1); FOR (i,1 , n) pref[i] = pref[i-1] + a[i].se; int mi = a[1].fi; int ans = 0; FOR (i, 2, n){ mi = max(mi, -pref[i-1] + a[i].fi); ans = max(ans, pref[i] - a[i].fi + mi); } cout << ans; return 0; }

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

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