Submission #211941

# Submission time Handle Problem Language Result Execution time Memory
211941 2020-03-21T19:36:10 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 maksi = 0, mini =  1000000000000001;
  ll max_so_far = -1000000000000001, 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:6: warning: unused variable 'maksi' [-Wunused-variable]
   ll maksi = 0, mini =  1000000000000001;
      ^~~~~
art.cpp:17:17: warning: unused variable 'mini' [-Wunused-variable]
   ll maksi = 0, mini =  1000000000000001;
                 ^~~~
art.cpp:18:59: warning: variable 'start' set but not used [-Wunused-but-set-variable]
   ll max_so_far = -1000000000000001, max_ending_here = 0, start =0, end = 0, s=0; 
                                                           ^~~~~
art.cpp:18:69: warning: variable 'end' set but not used [-Wunused-but-set-variable]
   ll max_so_far = -1000000000000001, 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 -