답안 #464973

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464973 2021-08-14T18:26:00 Z Blobo2_Blobo2 구경하기 (JOI13_watching) C++14
0 / 100
141 ms 31936 KB
/*
Editor: Abdelrahman Hossam
Nickname: Blobo2_Blobo2
IOI next year isA :)
*/
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define gen(arr,n,nxt)  generate(arr,arr+n,nxt)
#define Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty ios_base::sync_with_stdio(false);cin.tie(0);

const int mo=1e9+7,INF=1e18;
int nxt(){int x;cin>>x;return x;}
int n,sm,big,arr[2001],dp[2001][2001],mid;
int BS(int x){
    int s=0,e=n-1;
    while(s<=e){
        int mid=(s+e)>>1;
        if(arr[mid]>x)e=mid-1;
        else s=mid+1;
    }
    return e;
}
int check(int idx=0,int small=0){
    if(small>sm)
        return -1e9;
    if(idx>=n)
        return 0;
    int &ret = dp[idx][small];
    if(ret!=-1)return ret;
    int r = arr[idx] + mid;
    int idx2 = BS(r);
    return ret = max(check(idx2+1,small+1)+(idx2-idx+1),
                        check(idx+1,small));
}
int mn=1e18;
bool ok(){
    memset(dp,-1,sizeof dp);
    int x = check();
    vector<int>v;
    for(int i=0;i<n;i++)
        if(!dp[i][sm])
            v.push_back(arr[i]);
    int now=0,i=0;
    for(i;i<v.size();i++){
        now++;
        int r = v[i] + (mid*2);
        int s=0,e=v.size()-1;
        while(s<=e){
            int mid=(s+e)>>1;
            if(v[mid]>=r)e=mid-1;
            else s=mid+1;
        }
        i = e;
    }
    /*for(int j=0;j<v.size();j++)cout<<v[j]<<' ';
    cout<<endl;
    cout<<i<<' '<<mid<<' '<<now<<endl<<endl;*/
    if(i >= v.size()&&now<=big)
        return 1;
    else
        return 0;
}
signed main(){
    Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty
    n=nxt(),sm=nxt(),big=nxt();
    if(big+sm>=n){
        cout<<1;
        return 0;
    }
    gen(arr,n,nxt);
    sort(arr,arr+n);
    int s=0,e=1e9;
    while(s<=e){
        mid=(s+e)>>1;
        if(ok()){
            mn=min(mn,mid);
            e=mid-1;
        }
        else s=mid+1;
    }
    cout<<mn;
    return 0;
}

Compilation message

watching.cpp: In function 'bool ok()':
watching.cpp:52:9: warning: statement has no effect [-Wunused-value]
   52 |     for(i;i<v.size();i++){
      |         ^
watching.cpp:52:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(i;i<v.size();i++){
      |           ~^~~~~~~~~
watching.cpp:66:10: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |     if(i >= v.size()&&now<=big)
      |        ~~^~~~~~~~~~~
watching.cpp:46:9: warning: unused variable 'x' [-Wunused-variable]
   46 |     int x = check();
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 133 ms 31644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 141 ms 31936 KB Output isn't correct
2 Halted 0 ms 0 KB -