Submission #1178753

#TimeUsernameProblemLanguageResultExecution timeMemory
1178753vyaductArt Exhibition (JOI18_art)C++20
0 / 100
1 ms320 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; void setIo(string in="", string out=""){ if (!in.empty() && !out.empty()){ freopen(in.c_str(), "r", stdin); freopen(out.c_str(), "w", stdout); } ios::sync_with_stdio(false); cin.tie(0); } #define all(c) (c).begin(), (c).end() #define sz(c) (int)(c).size() #define vt vector #define pb push_back #define F first #define S second void solve(){ int n; cin>>n; vt<pair<ll,ll>> A(n); for (int i=0;i<n;i++){ cin>>A[i].F>>A[i].S; } sort(all(A)); vt<ll> pref(n+1); for (int i=0;i<n;i++) pref[i+1] = pref[i] + A[i].S; ll best=-1e18; for (int i=0;i<n;i++){ for (int j=i+1;j<n;j++){ ll Amax = A[j].F; ll Amin = A[i].F; ll S = pref[j+1] - pref[i]; best = max(best, S - (Amax - Amin)); } } cout << best << endl; } int main() { setIo(); int tt=1; // cin>>tt; while(tt--) solve(); return 0; }

Compilation message (stderr)

art.cpp: In function 'void setIo(std::string, std::string)':
art.cpp:7:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     freopen(in.c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:8:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     freopen(out.c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...