Submission #784937

# Submission time Handle Problem Language Result Execution time Memory
784937 2023-07-16T19:48:59 Z aykhn Watching (JOI13_watching) C++14
0 / 100
19 ms 468 KB
#include <bits/stdc++.h>

// author: aykhn

using namespace std;

typedef long long ll;

#define TC int t; cin >> t; while (t--) _();
#define OPT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pii pair<int, int>
#define mpr make_pair
#define eb emplace_back
#define new int32_t
#define pb push_back
#define ts to_string
#define fi first
#define se second
#define int ll
#define ins insert
#define inf 0x3F3F3F3F
#define infll 0x3F3F3F3F3F3F3F3FLL
#define bpc __builtin_popcount

new main()
{
    OPT
    int n, p, q;
    cin >> n >> p >> q;

    int a[n];

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    int l = 0;
    int r = 1e18;

    while (l < r)
    {
        int mid = (l + r) >> 1;

        set<pair<int, pii>> s;
        pair<int, pii> b[n];

        for (int i = 0; i < n; i++)
        {
            b[i].se.se = upper_bound(a, a + n, a[i] + 2 * mid - 1) - a - 1;
            b[i].se.fi = i;
            b[i].fi = b[i].se.se - b[i].se.fi + 1;
            b[i].fi *= -1;
            s.ins(b[i]);
        }

        int Q = q;

        while (Q--)
        {
            pair<int, pii> x = *s.begin();

            for (int i = x.se.fi; i <= x.se.se; i++)
            {
                if (s.find(b[i]) != s.end()) s.erase(b[i]);
            }
        }

        if (s.size() <= p) r = mid;
        else l = mid + 1;
    }

    cout << l << endl;
}

Compilation message

watching.cpp: In function 'int32_t main()':
watching.cpp:70:22: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   70 |         if (s.size() <= p) r = mid;
      |             ~~~~~~~~~^~~~
# 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 19 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -