답안 #1049946

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1049946 2024-08-09T06:17:09 Z vjudge1 Art Exhibition (JOI18_art) C++
0 / 100
0 ms 344 KB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Artwork {
    long long size;
    long long value;
};

long long maximizeArtExhibition(int N, vector<Artwork>& artworks) {
    sort(artworks.begin(), artworks.end(), [](const Artwork& a, const Artwork& b) {
        return a.size < b.size;
    });

    long long maxSMinusDiff = 0;
    long long totalValue = 0;
    long long A_min = artworks[0].size;

    for (int i = 0; i < N; ++i) {
        long long A_max = artworks[i].size;
        totalValue += artworks[i].value;
        long long currentSMinusDiff = totalValue - (A_max - A_min);
        maxSMinusDiff = max(maxSMinusDiff, currentSMinusDiff);
    }

    return maxSMinusDiff;
}

int main() {
    int N;
    cin >> N;

    vector<Artwork> artworks(N);
    for (int i = 0; i < N; ++i) {
        cin >> artworks[i].size >> artworks[i].value;
    }

    long long result = maximizeArtExhibition(N, artworks);
    cout << result << endl;

    return 0;
}
# 결과 실행 시간 메모리 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 -