Submission #211967

# Submission time Handle Problem Language Result Execution time Memory
211967 2020-03-21T20:54:53 Z Harry464 Art Exhibition (JOI18_art) C++14
0 / 100
5 ms 256 KB
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

#define ll long long

int main() {
  ll n;
  cin >> n;
  vector <pair <ll,ll> > a(n);
  for (int i = 0; i < n; i++)
   cin >> a[i].first >> a[i].second;
  sort(a.begin(),a.end());
  ll md = 0, ms = 0;
  vector <ll> kum(n+1,0);
  for (int i = 1; i <= n; i++)
   kum[i] = kum[i-1] + a[i-1].second;
  for (int i = 1; i <= n; i++){
    ll tren = kum[i] - a[i-1].first;
    ll md = min(md,kum[i-1] - a[i-1].first);
    tren -= md;
    ms = max(ms,tren);
  }
  cout << ms;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:17:6: warning: unused variable 'md' [-Wunused-variable]
   ll md = 0, ms = 0;
      ^~
art.cpp:23:8: warning: 'md' may be used uninitialized in this function [-Wmaybe-uninitialized]
     ll md = min(md,kum[i-1] - a[i-1].first);
        ^~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Incorrect 4 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Incorrect 4 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Incorrect 4 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Incorrect 4 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -