답안 #248890

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
248890 2020-07-13T17:08:12 Z rocks03 Art Exhibition (JOI18_art) C++14
0 / 100
3 ms 640 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define ff first
#define ss second
#define pb push_back

main(){
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    vector<pii> v(N);
    for(int i = 0; i < N; i++) cin >> v[i].ff >> v[i].ss;
    sort(v.begin(), v.end());
    ll ans = v[0].ss;
    set<pii> s; s.insert({v[0].ss+v[0].ff, 0});
    ll sum = v[0].ss;
    for(int i = 1; i < N; i++){
        pii best = *s.rbegin();
        ans = max(ans, best.ff - v[i].ff + v[i].ss);
        sum += v[i].ss;
        s.insert({sum+v[0].ff, 0});
        s.insert({best.ff - v[i].ff + v[i].ss, best.ss});
    }
    cout << ans;
}

Compilation message

art.cpp:9:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
art.cpp: In function 'int main()':
art.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("input.txt", "r", stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:11:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("output.txt", "w", stdout);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -