Submission #839837

#TimeUsernameProblemLanguageResultExecution timeMemory
839837ipslpArt Exhibition (JOI18_art)C++14
0 / 100
0 ms212 KiB
#include <iostream> #include <algorithm> using namespace std; int n; const int max_n = 5*1e5+5; pair<long long, long long> v[max_n]; bool comparator( pair<long long, long long> x, pair<long long, long long> y ) { if( x.first == y.first ) return x.second < y.second; return x.first < y.first; } int main() { ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); cin >> n; for( int i = 0; i < n; ++i ) cin >> v[i].first >> v[i].second; sort( v, v+n, comparator ); long long maxx = 0; unsigned long long sum = v[0].second; int st = 0, dr = 0; while( st < n && dr < n ) { if( sum - (v[dr].first - v[st].first) > 0 ) { if( sum - (v[dr].first - v[st].first) > maxx ) maxx = sum - (v[dr].first - v[st].first); ++dr, sum += v[dr].second; } else { ++st, sum -= v[st-1].second; } } cout << maxx; return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:27:51: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   27 |             if( sum - (v[dr].first - v[st].first) > maxx )
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...