Submission #1115324

#TimeUsernameProblemLanguageResultExecution timeMemory
1115324staszic_ojuzArt Exhibition (JOI18_art)C++17
50 / 100
1093 ms13600 KiB
#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 long long ll; struct Art { ll size; ll 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()); ll result = 0; for (uint beg = 0; beg < n; beg++) { pr(lv(beg)) ll sum = a[beg].val, max_a = a[beg].size, min_a = a[beg].size; result = max(result, a[beg].val); pr(lv(result)) 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); pr(lv(kon) lv(a[kon].size) lv(a[kon].val)) if (sum + min_a > max_a) { pr(lv(sum) lv(min_a) lv(max_a) lv(sum + min_a - max_a)) result = max(result, sum + min_a - max_a); } } pr() } cout << result << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...