Submission #876034

# Submission time Handle Problem Language Result Execution time Memory
876034 2023-11-21T06:28:19 Z Regulus Road Construction (JOI21_road_construction) C++17
6 / 100
148 ms 13768 KB
#include <bits/stdc++.h>            // pA
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define debug(x) cerr << #x << " = " << (x) << ' '
#define endl cerr << '\n'
#define all(v) (v).begin(), (v).end()
#define lowbit(x) (x)&-(x)
#define pb emplace_back
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

const int N = 3e5+5;
const int INF = 2e9;
ll n, Q;
pll p[N];
vector<ll> v;

inline bool chk(ll w)
{
    ll i, cnt = 0, L=1;

    for (i=1; i <= n; ++i)
    {
        while (p[i].F-p[L].F > w) ++L;
        cnt += i - L;
    }
    return cnt >= Q;
}

int main(void)
{ IO
    ll i, lb, mid, ub, j;

    cin >> n >> Q;
    for (i=1; i <= n; ++i) cin >> p[i].F >> p[i].S;

    sort(p+1, p+n+1);

    lb = 1, ub = 1e18;
    while (lb < ub)
    {
        mid = (lb+ub)>>1;
        if (chk(mid)) ub = mid;
        else lb = mid+1;
    }

    for (i=1; i <= n; ++i)
    {
        for (j=i-1; j >= 1; --j)
        {
            if (p[i].F-p[j].F > lb) break;
            v.pb(p[i].F-p[j].F);
        }
    }

    sort(all(v));
    for (i=0; i < Q; ++i) cout << v[i] << '\n';


    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 4804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 144 ms 7884 KB Output is correct
2 Correct 148 ms 10948 KB Output is correct
3 Correct 29 ms 5092 KB Output is correct
4 Correct 126 ms 11980 KB Output is correct
5 Correct 82 ms 12744 KB Output is correct
6 Correct 86 ms 13000 KB Output is correct
7 Correct 80 ms 13768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 108 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 108 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 4804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 4804 KB Output isn't correct
2 Halted 0 ms 0 KB -