제출 #1355448

#제출 시각아이디문제언어결과실행 시간메모리
1355448Miquella_Art Exhibition (JOI18_art)C++20
100 / 100
98 ms12184 KiB
#include <bits/stdc++.h>
#define pb push_back
#define se second
#define fi first
#define all(x) (x).begin(), (x).end()
#define el "\n"
#define bit(mask,i) ((mask>>i)&1)
#define vll vector <long long>
#define FOR(i, a, b) for (int i = a; i <= b; i ++)
#define REP(i, a, b) for (int i = a; i >= b; i --)
#define taskname "test"
#define int long long
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;

const int MAXN = 1e6+5;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double EPSILON = 0.000001;

// Initial function
ll add(ll x, ll y) {
    x += y;
    if (x >= MOD) x -= MOD;
    if (x < 0) x += MOD;
    return x;
}

void maximize (ll &x, ll val) {
    x = max (x, val);
}

void minimize (ll &x, ll val) {
    x = min (x, val);
}

ll Pow (ll x, ll y) {
    int ans = 1;
    while (y > 0) {
        if (y & 1) ans = ans * x % MOD;
        y /= 2;
        x = x * x % MOD;
    }
    return ans;
}

// -----------------------

int n, f[MAXN];
pi a[MAXN];

void solve () {
    cin >> n;
    FOR (i, 1, n) cin >> a[i].fi >> a[i].se;

    sort (a + 1, a + 1 + n);

    int res = 0;
    FOR (i, 1, n) {
        f[i] = max (a[i].se, f[i - 1] + a[i].se - (a[i].fi - a[i - 1].fi));
        maximize (res, f[i]);
    }

    cout << res;
}


signed main ()
{
    if (fopen (taskname".inp", "r"))
    {
        freopen (taskname".inp", "r", stdin);
        freopen (taskname".out", "w", stdout);
    }

    ios_base :: sync_with_stdio (false);
    cin.tie (NULL);
    cout.tie (NULL);

    clock_t start = clock();

    solve ();

    std::cerr << "Time elapsed: " << clock() - start << " ms\n";
    
    return 0;
}

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

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