제출 #1086054

#제출 시각아이디문제언어결과실행 시간메모리
1086054kiethm07Art Exhibition (JOI18_art)C++11
0 / 100
0 ms344 KiB
#include <bits/stdc++.h> #define pii pair<int,int> #define iii pair<int,pii> #define fi first #define se second #define vi vector<int> #define all(x) x.begin(),x.end() #define TEXT "a" using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; const int inf = 1e9 + 7; const ld eps = 1e-8; const double pi = acos(-1); const int N = 5e5 + 5; struct node{ ll a, b; bool operator < (const node& N) const{ if (a != N.a) return a < N.a; return b < N.b; } node(){} }; int n; node v[N]; ll p[N]; ll backtrack(ll M, ll m, ll s, ll i){ if (i > n){ if (M == LLONG_MIN) return LLONG_MIN; return s - (M - m); } ll res = LLONG_MIN; res = max(res,backtrack(max(M,v[i].a),min(m,v[i].a), s + v[i].b, i + 1)); res = max(res,backtrack(M,m,s,i + 1)); return res; } int main(){ cin.tie(0) -> sync_with_stdio(0); if (fopen(TEXT".inp","r")){ freopen(TEXT".inp","r",stdin); freopen(TEXT".out","w",stdout); } ll res = LLONG_MIN; cin >> n; for (int i = 1; i <= n; i++){ cin >> v[i].a >> v[i].b; } sort(v + 1,v + 1 + n); for (int i = 1; i <= n; i++){ p[i] = p[i - 1] + v[i].b; } ll cur = v[1].a; for (int i = 1; i <= n; i++){ res = max(res,p[i] - v[i].a + cur); cur = max(cur,v[i].a - p[i]); } cout << res << "\n"; //cout << backtrack(LLONG_MIN, LLONG_MAX, 0, 1) << "\n"; return 0; }

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

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