Submission #366242

#TimeUsernameProblemLanguageResultExecution timeMemory
366242Tuk1352Art Exhibition (JOI18_art)C++11
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> using namespace std; int main () { int n; cin >> n; long long A, S, MS=0, Su=0, Sd, I=0; vector <pair<long long, long long>> V; for (int i = 0; i < n; i++) { cin >> A >> S; V.push_back({A, S}); } sort(V.begin(), V.end()); for (int i = 0; i < V.size(); i++) { Su += V[i].second; Sd = Su - (V[i].first - V[I].first); while (Sd < 0) { I++; Sd = Su - (V[i].first - V[I].first); } MS = max(MS, Sd); } cout << MS; return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 0; i < V.size(); i++)
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...