제출 #523145

#제출 시각아이디문제언어결과실행 시간메모리
523145Jarif_RahmanArt Exhibition (JOI18_art)C++17
50 / 100
1076 ms20664 KiB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;

    ll ans = 0, mx = 0;

    vector<pair<ll, ll>> v(n);
    for(auto &p: v) cin >> p.f >> p.sc, ans = max(ans, p.sc);
    sort(v.begin(), v.end());

    mx = v[0].sc;

    for(int i = 1; i < n; i++){
        ll cur = v[i].sc;
        for(int j = i-1; j >= 0; j--){
            cur+=v[j].sc;
            ans = max(ans, cur-v[i].f+v[j].f);
        }
    }

    cout << ans << "\n";
}

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

art.cpp: In function 'int main()':
art.cpp:13:17: warning: variable 'mx' set but not used [-Wunused-but-set-variable]
   13 |     ll ans = 0, mx = 0;
      |                 ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...