제출 #1281587

#제출 시각아이디문제언어결과실행 시간메모리
1281587dungntArt Exhibition (JOI18_art)C++20
100 / 100
151 ms12116 KiB
#include<bits/stdc++.h>
#define M 500004
#define ll long long
#define fi first
#define se second
using namespace std;

int n;
pair<ll, int> p[M];
ll s[M];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);     cout.tie(0);
    #define name "baitap"
    if(fopen(name".inp", "r"))
    {
        freopen(name".inp", "r", stdin);
        freopen(name".out", "w", stdout);
    }
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> p[i].fi >> p[i].se;
    sort(p + 1, p + n + 1);
    for(int i = 1; i <= n; i++)
        s[i] = s[i - 1] + p[i].se;
    ll cur = -1e18, ans = -1e18;
    for(int i = 1; i <= n; i++)
    {
        cur = max(cur, p[i].fi - s[i - 1]);
        ans = max(ans, cur + s[i] - p[i].fi);
    }
    cout << ans;
}

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

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