답안 #1106757

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1106757 2024-10-31T02:52:18 Z vjudge1 Art Exhibition (JOI18_art) C++14
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 = 1e6+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 = a[1].se;
    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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -