Submission #503345

#TimeUsernameProblemLanguageResultExecution timeMemory
503345OrazBArt Exhibition (JOI18_art)C++14
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> #define N 500005 #define ll long long int #define pii pair <long long, long long> #define pb push_back #define ff first #define ss second using namespace std; ll t, n, S, mx, c[N], mn = 1e9, ans; pii a[N]; // void bit (int x){ // if (x == n + 1){ // S = mx = 0; // mn = 1e9; // for (int i = 1; i <= n; i++){ // if (c[i]){ // S += a[i].ss; // mx = max(mx, a[i].ff); // mn = min(mn, a[i].ff); // } // if (S - (mx - mn) == 7){ // for (int i = 1; i <= n; i++) cout << c[i] << " "; // exit(0); // } // } // return; // } // for (int i = 0; i < 2; i++) c[x] = i, bit(x + 1); // } int main () { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i].ff >> a[i].ss; // bit(1); sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++){ S += a[i].ss; mx = max(mx, a[i].ff); mn = min(mn, a[i].ff); ans = max(ans, S - (mx - mn)); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...