Submission #1109231

# Submission time Handle Problem Language Result Execution time Memory
1109231 2024-11-06T08:36:13 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
2 ms 336 KB
#include "bits/stdc++.h"
using namespace std;
#define int long long
const int N = 5e5+7;
struct picture {
    int a, b;
} d[N];
int n, ps[N], f[N];
bool cmp(picture x, picture y){
    if(x.a == y.a) return x.b < y.b;
    return x.a < y.a;
}
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    freopen("TL.INP", "r", stdin);
    freopen("TL.OUT", "w", stdout);
    cin>>n;
    for(int i = 1; i <= n; i++){
        cin>>d[i].a>>d[i].b;
    }
    sort(d+1, d+n+1, cmp);
    int res = 0;
    for(int i = 1; i <= n; i++){
        ps[i] = ps[i-1]+d[i].b;
        f[i] = max(f[i-1], d[i].a-ps[i-1]);
        res = max(ps[i]-d[i].a+f[i], res);
    }
    cout<<res;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen("TL.INP", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
art.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen("TL.OUT", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -