Submission #990833

# Submission time Handle Problem Language Result Execution time Memory
990833 2024-05-31T13:13:59 Z 12345678 Road Construction (JOI21_road_construction) C++17
6 / 100
478 ms 57576 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int nx=250005;

ll n, k, x[nx], y;
set<pair<ll, ll>> s;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>k;
    for (int i=0; i<n; i++) cin>>x[i]>>y;
    sort(x, x+n);
    priority_queue<tuple<ll, ll, ll>, vector<tuple<ll, ll, ll>>, greater<tuple<ll, ll, ll>>> pq;
    for (int i=0; i<n-1; i++) pq.push({x[i+1]-x[i], i, i+1}), s.insert({i, i+1});
    for (int t=1; t<=k; t++)
    {
        auto [d, a, b]=pq.top();
        pq.pop();
        cout<<d<<'\n';
        if (a!=0&&s.find({a-1, b})==s.end()) pq.push({x[b]-x[a-1], a-1, b}), s.insert({a-1, b});
        if (b!=n-1&&s.find({a, b+1})==s.end()) pq.push({x[b+1]-x[a], a, b+1}), s.insert({a, b+1});
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 187 ms 18508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 478 ms 51692 KB Output is correct
2 Correct 468 ms 53488 KB Output is correct
3 Correct 168 ms 18772 KB Output is correct
4 Correct 297 ms 43508 KB Output is correct
5 Correct 219 ms 43756 KB Output is correct
6 Correct 210 ms 43752 KB Output is correct
7 Correct 243 ms 57576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 105 ms 24040 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 105 ms 24040 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 187 ms 18508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 187 ms 18508 KB Output isn't correct
2 Halted 0 ms 0 KB -