Submission #666258

#TimeUsernameProblemLanguageResultExecution timeMemory
666258Bogdan1110Art Exhibition (JOI18_art)C++14
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> #define FAST {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);} #define FILES {freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);} #define ll long long #define ull unsigned long long #define pqueue priority_queue #define pb push_back #define fi first #define se second #define ld long double #define pii pair<int,int> #define pll pair<long long,long long> #define all(a) (a).begin(), (a).end() #define mp make_pair using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update> // order_of_key -> # less than k // find_by_order -> k-th element // pq max element const double eps = 0.00000001; const int NMAX = 2000010; const ll inf = LLONG_MAX/3; const ll modi = 998244353; void solve() { int n; cin >> n; vector<pll>v(n); vector<ll>vv(n); for (int i = 0 ; i < n ; i++ ) { cin >> v[i].fi >> v[i].se; } sort(all(v)); for (int i = 0 ; i < n ; i++ ) vv[i] = v[i].se; for (int i = 1 ; i < n ; i++ ) { v[i].se += v[i-1].se; } ll res = LLONG_MIN; ll minn = inf; ll sum = 0; for (int i = 0 ; i < n ; i++ ) { minn = min(minn, sum - v[i].fi); sum += v[i].se; res = max(res, v[i].se - v[i].fi - minn); //cout << res << endl; } cout << res << endl; } int main () { FAST int t=1; /* cin >> t; //*/ int i = 1; while(t--) { //cout << "Case #" << i++ << ": " ; solve(); } }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:72:9: warning: unused variable 'i' [-Wunused-variable]
   72 |     int i = 1;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...