답안 #1108472

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1108472 2024-11-04T08:14:34 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 6e5 + 1;
int pre[N],n;
pair<int,int> a[N];
signed main()
{
    freopen("code.inp","r",stdin);
    freopen("code.out","w",stdout);
    cin >> n;
    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i].first >> a[i].second;
     }
     sort(a+1,a+n+1);
     for(int i = 1; i <= n; i ++)
     {
         pre[i] = pre[i-1] + a[i].second;
     }
     int minn = 1e18,ans = -1e18;
     for(int i = 1; i <= n; i++)
     {  minn = min(pre[i-1]-a[i].first,minn);
        ans = max(ans,pre[i] - a[i].first - minn);

     }
     cout << ans;
    return 0;
}

Compilation message

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