답안 #975626

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
975626 2024-05-05T15:01:58 Z vjudge1 구경하기 (JOI13_watching) C++17
0 / 100
1000 ms 344 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define v(a) vector<a>

v(ll) arr;
ll n, p, q; 
ll binsearch(ll l, ll r, ll c1){
    if(l <= r){
        ll mid = (l+r)/2;
        ll cur = 2*mid*c1;
        bool ok = false;
        ll pos = upper_bound(arr.begin(), arr.end(), cur)-arr.begin()-1;
        // cout << pos << " " << mid <<  '\n';
        if(n-pos-1 <= p) ok = true;
        if(ok) return min(mid, binsearch(l, mid-1, c1));
        return binsearch(mid+1, r, c1);

    }
}
int main(){
    cin >> n >> p >> q;
    arr.resize(n);
    for(int i = 0; i < n; i++) cin >> arr[i];
    sort(arr.begin(), arr.end());
    if(p >= n || q >= n) cout << 1;
    else {
        cout << binsearch(1, 1e9, q);
    }
}

Compilation message

watching.cpp: In function 'long long int binsearch(long long int, long long int, long long int)':
watching.cpp:21:1: warning: control reaches end of non-void function [-Wreturn-type]
   21 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1035 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1016 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -