답안 #973858

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
973858 2024-05-02T11:57:45 Z Hectorungo_18 Art Exhibition (JOI18_art) C++14
0 / 100
0 ms 344 KB
#include <iostream>
#include <bits/stdc++.h>
#include <list>
#include <set>
#include <cstdio>

using namespace std;
#define int unsigned long long
#define f first
#define s second 
#define all(x) x.begin(), x.end()


void solve(){
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    for(int i = 0; i < n; i++) cin >> v[i].f >> v[i].s;

    sort(all(v));
    vector<pair<int, int>> w;
    for(int i = 0; i < n; i++){
        if(w.size() == 0 || v[i].f != w.back().f){
            w.push_back(v[i]);
        }
        else{
            w.back().s+=v[i].s;
        }
    }
    v = w;
    int ans = v[0].s;


    int bf = v[0].f;
    int cur = v[0].s;

    for(int i = 1; i < n; i++){
        int ad = v[i].s;
        int re = v[i].f-v[i-1].f;
        if(cur+ad-re < 0){
            cur = ad;
            ans = max(ans, cur);
            continue;
        }
        cur+=ad-re;
        ans=max(ans, cur);
    }

    cout << ans << endl;


}


signed main() {
    int t = 1;
    // cin >> t;
    while(t--) solve();

    return 0;
}

Compilation message

art.cpp: In function 'void solve()':
art.cpp:34:9: warning: unused variable 'bf' [-Wunused-variable]
   34 |     int bf = v[0].f;
      |         ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -