Submission #211944

# Submission time Handle Problem Language Result Execution time Memory
211944 2020-03-21T19:38:06 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 max_so_far = -100000000000000001, max_ending_here = 0, start =0, end = 0, s=0; 
  
    for (int i=0; i< n; i++ ) 
    { 
        max_ending_here += a[i].second; 
        if (i > 0)
         max_ending_here -= a[i].first - a[i-1].first;
        if (max_so_far < max_ending_here) 
        { 
            max_so_far = max_ending_here; 
            start = s; 
            end = i; 
        } 
  
        if (max_ending_here < 0) 
        { 
            max_ending_here = 0; 
            s = i + 1; 
        } 
    } 
    cout << max_so_far << endl; 
   
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:17:61: warning: variable 'start' set but not used [-Wunused-but-set-variable]
   ll max_so_far = -100000000000000001, max_ending_here = 0, start =0, end = 0, s=0; 
                                                             ^~~~~
art.cpp:17:71: warning: variable 'end' set but not used [-Wunused-but-set-variable]
   ll max_so_far = -100000000000000001, max_ending_here = 0, start =0, end = 0, s=0; 
                                                                       ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -