제출 #1222479

#제출 시각아이디문제언어결과실행 시간메모리
1222479Bui_Quoc_CuongArt Exhibition (JOI18_art)C++20
50 / 100
40 ms5188 KiB
#include<bits/stdc++.h>
using namespace std;

typedef pair <int, int> pii;
typedef vector <int> vi;
typedef long long ll;

#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (int)(a.size())

const int N = 3e5 + 5;
const int oo = 2e9;
const int MOD = 1e9 + 7;
const ll INF = 1e18;

int n;
array <ll, 2> artwork[N];

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define taskname "kieuoanh"
    if(fopen(taskname".inp", "r")){
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
    cin >> n;
    FOR(i, 1, n) cin >> artwork[i][0] >> artwork[i][1];
    sort(artwork + 1, artwork + 1 + n);

    ll ans = - 1e18;
    FOR(i, 1, n){
    	ll S = 0;
        ll mn = 1e18, mx = 0;
    	FOR(j, i, n){
            S+= artwork[j][1];
            mn = min(mn, artwork[j][0]);
            mx = max(mx, artwork[j][0]);
            ans = max(ans, S - (mx - mn));
    	}
    }
    cout << ans;

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

art.cpp: In function 'int main()':
art.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...