Submission #1106751

# Submission time Handle Problem Language Result Execution time Memory
1106751 2024-10-31T02:42:39 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 336 KB
#include<bits/stdc++.h>
#define forinc(i,a,b) for(int i=a;i<=b;i++)
#define fordec(i,a,b) for(int i=a;i>=b;i--)
#define int long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
using namespace std;
const int N = 5e5+10;
int n,sum[N];
pii a[N];

int32_t main()
{
    #define task "task"
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    forinc(i,1,n) cin>>a[i].fi>>a[i].se;
    sort(a+1,a+n+1);
    int kq = 0;
    int s = a[1].se;
    int mx = a[1].fi;
    forinc(i,2,n)
    {
        kq = max(kq , s + a[i].se - a[i].fi + mx);
        mx = max(mx , a[i].fi - s);
        s += a[i].se;
    }
    cout<<kq;


}

Compilation message

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