Submission #1115288

# Submission time Handle Problem Language Result Execution time Memory
1115288 2024-11-20T09:54:16 Z staszic_ojuz Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 336 KB
#include<bits/stdc++.h>
#ifdef _DEBUG
#define ls(x) << x << ", "
#define lv(x) << #x << ": " << flush << x << ", "
#define pr(x) cout << "Line: " << __LINE__ << ", " x << endl;
#else
#define ls(x)
#define lv(x)
#define pr(x) ;
#endif
using namespace std;
typedef unsigned int uint;
typedef unsigned long long ull;

struct Art {
    ull size;
    uint val;
};

bool operator<(Art a, Art b) {
    return a.size < b.size;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    uint n;
    cin >> n;
    vector<Art> a(n);
    for (uint i = 0; i < n; i++) {
        cin >> a[i].size >> a[i].val;
    }
    sort(a.begin(), a.end());
    ull result = 0;
    for (uint beg = 0; beg < n-1; beg++) {
        ull sum = a[beg].val, max_a = a[beg].size, min_a = a[beg].size;
        for (uint kon = beg+1; kon < n; kon++) {
            sum += a[kon].val;
            max_a = max(max_a, a[kon].size);
            min_a = min(min_a, a[kon].size);
            if (sum + min_a > max_a) {
                result = max(result, sum + min_a - max_a);
            }
        }
    }
    cout << result << '\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -