답안 #968253

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968253 2024-04-23T08:53:59 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[500001],p[500001];
int main() {
    cin.tie(0)->sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> a[i] >> p[i];
    }
    ll mini=a[0],maxi=a[0];
    ll s=p[0];
    ll mx;
    for (int i=1;i<n;i++) {
        mx = max(p[i],max(s-maxi+mini,s-max(maxi,a[i])+min(mini,a[i])+p[i]));
        if (s-max(maxi,a[i])+min(mini,a[i])+p[i] == mx) {
            s+=p[i];
            mini = min(mini,a[i]);
            maxi = max(maxi,a[i]);
        } else if (p[i] == mx){
            s = p[i];
            mini=a[i];
            maxi=a[i];
        }
    }
    cout << s-maxi+mini;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -