Submission #1169155

#TimeUsernameProblemLanguageResultExecution timeMemory
1169155zaki98Art Exhibition (JOI18_art)C++20
100 / 100
125 ms8264 KiB
#include "bits/stdc++.h" typedef long long ll; #define F first #define S second #define PB push_back #define MP make_pair #define pii pair<int,int> #define pll pair<long long, long long> // last layer permutation #define LOO(i,a,b) for (int i = a; i <= b; i++) #define max3(a, b, c) max(max(a, b), c) #define min3(a, b, c) min(min(a, b), c) using namespace std; const ll MAX = 1e9 + 7; void iO() { freopen("output.txt","w",stdout); freopen("input.txt","r",stdin); } vector<int> make_sorted_index(vector<int> const& values) { vector<int> index(values.size()); iota(index.begin(), index.end(), 0); stable_sort(index.begin(), index.end(), [&values](int a, int b) { return values[a] < values[b]; } ); return index; } // this function is so skibidi ll iPow(ll x, unsigned int p) { if (p == 0) return 1; if (p == 1) return x; ll tmp = iPow(x, p/2); if (p%2 == 0) return (tmp * tmp); else return (((x * tmp)) * tmp); } int solve() { int n; cin >> n; vector<pll> beautfiul(n); LOO(i,0, n-1) { ll a, b; cin >> a >> b; beautfiul[i] = MP(a, b); } sort(beautfiul.begin(), beautfiul.end()); ll prev = beautfiul[0].F; ll maxy_sof = 0; ll currenty = 0; LOO(i, 0, n-1) { currenty += prev - beautfiul[i].F; if (currenty < 0) currenty = 0; currenty += beautfiul[i].S; maxy_sof = max(maxy_sof, currenty); prev = beautfiul[i].F; } cout << maxy_sof << '\n'; return 0; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // iO(); //pre_process(); int t = 1; // cin >> t; while (t--) { solve(); // cout << flush; } }

Compilation message (stderr)

art.cpp: In function 'void iO()':
art.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen("output.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:17:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     freopen("input.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...