답안 #1106754

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1106754 2024-10-31T02:46:56 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 = 5e3+10;
int n,s[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);
    for(int i = 1 ; i<=n;i++) s[i] = s[i-1] + a[i].se;
    int kq = a[1].se;
    for(int i =2;i<=n;i++)
    {
        for(int j = i-1;j>=1;j--) kq = max(kq,s[i] - s[j-1] - (a[i].fi - a[j].fi));
    }
    cout<<kq;

}

Compilation message

art.cpp: In function 'int32_t main()':
art.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
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".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 -