Submission #1115288

#TimeUsernameProblemLanguageResultExecution timeMemory
1115288staszic_ojuzArt Exhibition (JOI18_art)C++17
0 / 100
1 ms336 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 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...