Submission #112304

#TimeUsernameProblemLanguageResultExecution timeMemory
112304MercenaryArt Exhibition (JOI18_art)C++14
100 / 100
480 ms28792 KiB
#include<bits/stdc++.h>

using namespace std;
#define taskname "A"
#define pb	push_back
#define mp 	make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 1e6;
int n;
pair<ld,ld> a[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    for(int i = 1 ; i <= n ; ++i){
        cin >> a[i].first >> a[i].second;
    }
    sort(a + 1 , a + n + 1);
    ld res = 0;
    ld now = -1e21;
    for(int i = 1 ; i <= n ; ++i){
        a[i].second += a[i - 1].second;
        now = max(+a[i].first-a[i - 1].second,now);
        res = max(res , -a[i].first + a[i].second + now);
//        cout << now << endl;
    }
    cout << fixed << setprecision(0) << res;
}

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:22:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".INP", "r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:23:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".OUT", "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...