답안 #305539

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
305539 2020-09-23T13:34:13 Z theshadow_04 구경하기 (JOI13_watching) C++17
0 / 100
1 ms 384 KB
// W i B
#include <bits/stdc++.h>
#define F first
#define S second
#define MOD 998244353
#define pb push_back
#define bit(x,p) ((x>>p) & 1)
#define ll long long
#define Task "Ojuz"
using namespace std;

const int base = 100003;
const int maxn = 1000005;

int n,p,q;
int a[maxn];

bool Check(int x){
    int s = p,l = q,i = 1;
    for(;i <= n;){
        int pos1 = upper_bound(a + 1,a + n + 1,a[i] + x - 1) - a - 1;
        int pos2 = upper_bound(a + 1,a + n + 1,a[i] + 2 * x - 1) - a - 1;
        if(pos2 > pos1 && l) i = pos2 + 1,l --;
        else if(s) i = pos1 + 1,s--;
        else break;
    }
    return (i >= n);
}

void Solve(){
    cin >> n >> p >> q;
    a[n + 1] = 2e9;
    for(int i = 1;i <= n;++i) cin >> a[i];
    sort(a + 1,a + n + 1);
    int l = 0,r = 2e9;
    while(r - l > 1){
        int mid = (l + r) >> 1;
        if(Check(mid)) r = mid;
        else l = mid;
    }
    cout << r;
}

void NumTime(){
    cerr << "Toi" << "\n";cerr << "Di" << "\n";cerr << "Chep" << "\n";cerr << "Code" << "\n";
}

int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
	if(fopen(Task".inp","r")){
		freopen(Task".inp","r",stdin);
		freopen(Task".out","w",stdout);
	}
    int test = 1;
//    cin >> test;
    while(test --){
        NumTime();
        Solve();
    }
}
 // V T An

Compilation message

watching.cpp: In function 'int main()':
watching.cpp:52:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   52 |   freopen(Task".inp","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
watching.cpp:53:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   53 |   freopen(Task".out","w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -