제출 #773285

#제출 시각아이디문제언어결과실행 시간메모리
773285teokakabadzeArt Exhibition (JOI18_art)C++17
100 / 100
142 ms24860 KiB
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define int long long
#define N 500005
#define pii pair<int, int>
using namespace std;

int n, i, j, mx, ans, dp[N];
pii a[N];

main()
{
    std::ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    for(i = 0; i < n; i++)
    cin >> a[i].f >> a[i].s;
    sort(a, a + n);
    for(i = 0; i < n; i++)
    {
        dp[i] = max(a[i].s, mx + a[i].s - a[i].f);
        mx = max(mx, dp[i] + a[i].f);
        ans = max(ans, dp[i]);
    }
    cout << ans << '\n';
}

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

art.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...