답안 #1041011

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041011 2024-08-01T13:54:27 Z alexdd Road Construction (JOI21_road_construction) C++17
0 / 100
10000 ms 4884 KB
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n,cate,k;
pair<int,int> p[250005];
vector<int> sol;
int afis(int lim, bool bl)
{
    sol.clear();
    int poz=1,cnt=0;
    set<pair<int,int>> s;
    for(int i=1;i<=n;i++)
    {
        while(p[i].first-p[poz].first>lim)
        {
            s.erase({p[poz].second,p[poz].first});
            poz++;
        }
        for(auto it = s.lower_bound({p[i].second-lim,-1});it!=s.lower_bound({p[i].second+lim,INF});it++)
        {
            if(bl) sol.push_back(max(abs(p[i].first-(*it).second),abs(p[i].second-(*it).first)));
            cnt++;
            if(cnt > k)
                return k+1;
        }
        s.insert({p[i].second,p[i].first});
    }
    return cnt;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i].first>>p[i].second;
        p[i] = {p[i].first+p[i].second, p[i].first-p[i].second};
    }
    sort(p+1,p+1+n);
    int st=0,dr=INF,ans=0;
    while(st<=dr)
    {
        int mij=(st+dr)/2;
        if(afis(mij,0)<=k)
        {
            ans=mij;
            st=mij+1;
        }
        else
            dr=mij-1;
    }
    afis(ans,1);
    sort(sol.begin(),sol.end());
    for(auto x:sol)
        cout<<x<<"\n";
    for(int i=1;i<=k-afis(ans,0);i++)
        cout<<ans+1<<"\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10089 ms 732 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 375 ms 4884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 224 ms 2304 KB Output is correct
2 Correct 195 ms 2384 KB Output is correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 224 ms 2304 KB Output is correct
2 Correct 195 ms 2384 KB Output is correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10089 ms 732 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10089 ms 732 KB Time limit exceeded
2 Halted 0 ms 0 KB -