제출 #1144273

#제출 시각아이디문제언어결과실행 시간메모리
1144273Robert_juniorArt Exhibition (JOI18_art)C++20
0 / 100
0 ms324 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define ins insert
#define all(x) x.begin(), x.end()
#define F first
#define S second
const int N  = 200100, k = 350;
void solve(){
    int n;
    cin>>n;
    vector<pair<int, int>>v(n);
    for(int i = 0; i < n; i++){
        cin>>v[i].F>>v[i].S;
    }
    sort(all(v));
    int mx = -1e18;
    int cur = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        cout<<v[i].F<<' '<<v[i].S<<'\n';
        mx = max(mx, v[i].F - cur);
        cur += v[i].S;
        ans = max(ans, cur - v[i].F + mx);
    }
    cout<<ans;
}
main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
}

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

art.cpp:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 | 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...