답안 #163273

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
163273 2019-11-12T06:34:04 Z aggu_01000101 구경하기 (JOI13_watching) C++14
0 / 100
93 ms 504 KB
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n, p, q;
    cin>>n>>p>>q;
    int a[n];
    for(int i = 0;i<n;i++) cin>>a[i];
    //cout<<"DONE WITH INPUT"<<endl;
    sort(a, a+n);
    int u = 1e9;
    int l = 1;
    int mini = 1e9;
    while(u>=l){
        int m = (l+u)/2;
        //cout<<m<<endl;
        int covered = n;
        int p1 = p, q1 = q;
        int b[n];
        for(int i = 0;i<n;i++) b[i] = a[i];
        while(q1 && covered>0){
            pair<int, int> count = make_pair(0, 0);
            int j = 0;
            for(int i = 0;i<covered;i++){
                while(j<covered && b[j]<(2*m+b[i])) j++;
                if(count.first<(j-i)) count = make_pair(j-i, i);
                i = j-1;
            }
            //cout<<(covered-count.first)<<" ARE STILL LEFT"<<endl;
            for(int i = count.second;(i+count.first)<covered;i++){
                b[i] = b[i+count.first];
            }
            //cout<<"PRINTING ARRAY: ";
            covered-=count.first;
            //for(int i = 0;i<covered;i++) cout<<b[i]<<" ";
            //cout<<endl;
            q1--;
        }
        while(covered>0){
            int left = covered;
            int j = 0;
            for(int i = 0;i<left;i++){
                if(p1==0) goto outer;
                while(j<left && b[j]<(m+b[i])) j++;
                covered-=(j-i);
                i = j-1;
                p1--;
            }
        }
        outer:
        //cout<<l<<" "<<u<<" "<<m<<" "<<covered<<endl;
        if(covered==0){
            u = m-1;
            mini = min(m, mini);
        }
        else{
            l  = m+1;
        }
    }
    cout<<mini<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 492 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Incorrect 2 ms 256 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 380 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 80 ms 392 KB Output is correct
4 Correct 15 ms 376 KB Output is correct
5 Correct 91 ms 504 KB Output is correct
6 Correct 93 ms 504 KB Output is correct
7 Incorrect 4 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -