Submission #839834

# Submission time Handle Problem Language Result Execution time Memory
839834 2023-08-30T18:12:14 Z ipslp Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 212 KB
#include <iostream>
#include <algorithm>
using namespace std;
int n;
const int max_n = 5*1e5;
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()
{
    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;
    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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -