Submission #1115351

#TimeUsernameProblemLanguageResultExecution timeMemory
1115351staszic_ojuzArt Exhibition (JOI18_art)C++17
50 / 100
1020 ms23624 KiB
#include <iostream> #include <algorithm> #include <cmath> #include <queue> #include <vector> #include <stack> #include <unordered_map> using namespace std; typedef long long ll; struct dzielo { ll s; ll v; }; struct triple { ll a; ll b; ll c; }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; vector<dzielo> arts(n); for(int i = 0; i < n; i++) { ll s, v; cin >> s >> v; arts[i].s = s; arts[i].v = v; } sort(arts.begin(), arts.end(), [](dzielo a, dzielo b) {return a.s < b.s;}); vector<ll> sp(n + 1); for(int i = 0; i < n; i++) { sp[i + 1] = sp[i] + arts[i].v; } // vector<triple> diff(n - 1); // for(int i = 0; i < n - 1; i++) { // diff[i].a = arts[i + 1].s - arts[i].s; // diff[i].b = i; // diff[i].c = arts[i + 1].v + arts[i].v; // } ll mx = 0; for(int i = 0; i < n; i++) { dzielo d = arts[i]; for(int j = i; j < n; j++) { dzielo o = arts[j]; mx = max(mx, sp[j + 1] - sp[i] - o.s + d.s); //cout << d.s << " " << d.v << " dsv " << o.s << " " << o.v << " osv " << i << " " << j << " ij " << sp[j + 1] << " " << sp[i] << endl; //cout << sp[j + 1] - sp[i] - o.s + d.s << endl; } } cout << mx; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...