답안 #43806

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43806 2018-03-24T03:43:07 Z top34051 구경하기 (JOI13_watching) C++14
50 / 100
329 ms 16324 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e3 + 5;
int n,p,q;
vector<ll> t;
ll a[maxn];
int warp1[maxn], warp2[maxn];
int dp[maxn][maxn];
int solve(int w) {
    for(int x=1,y1=1,y2=1;x<=n;x++) {
        while(y1<=n && a[x] + w > a[y1]) y1++;
        while(y2<=n && a[x] + w*2 > a[y2]) y2++;
        warp1[x] = y1; warp2[x] = y2;
    }
    for(int x=n;x>=1;x--) {
        for(int i=0;i<=p;i++) {
            dp[x][i] = dp[warp2[x]][i] + 1;
            if(i) dp[x][i] = min(dp[x][i], dp[warp1[x]][i-1]);
        }
    }
    return dp[1][p]<=q;
}
int main() {
    scanf("%d%d%d",&n,&p,&q);
    for(int i=1;i<=n;i++) {
        ll x;
        scanf("%lld",&x);
        t.push_back(x);
    }
    sort(t.begin(),t.end());
    t.erase(unique(t.begin(),t.end()),t.end());
    n = (int)t.size();
    for(int i=1;i<=n;i++) a[i] = t[i-1];
    //fuck you
    if(p+q>=n) return !printf("1");
    //solve
    ll l = 0, r = 2e9, mid, res;
    while(l<=r) {
        mid = (l+r)/2;
        if(solve(mid)) res = mid, r = mid-1;
        else l = mid+1;
    }
    printf("%lld",res);
}

Compilation message

watching.cpp: In function 'int main()':
watching.cpp:25:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&p,&q);
                             ^
watching.cpp:28:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&x);
                         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 760 KB Output is correct
2 Correct 1 ms 760 KB Output is correct
3 Correct 1 ms 760 KB Output is correct
4 Correct 1 ms 760 KB Output is correct
5 Correct 1 ms 760 KB Output is correct
6 Correct 2 ms 760 KB Output is correct
7 Correct 2 ms 1044 KB Output is correct
8 Correct 2 ms 1044 KB Output is correct
9 Correct 2 ms 1044 KB Output is correct
10 Correct 2 ms 1044 KB Output is correct
11 Correct 2 ms 1044 KB Output is correct
12 Correct 2 ms 1044 KB Output is correct
13 Correct 2 ms 1044 KB Output is correct
14 Correct 2 ms 1044 KB Output is correct
15 Correct 2 ms 1044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8640 KB Output is correct
2 Correct 2 ms 8640 KB Output is correct
3 Correct 2 ms 8640 KB Output is correct
4 Correct 2 ms 8640 KB Output is correct
5 Correct 2 ms 8640 KB Output is correct
6 Correct 2 ms 8640 KB Output is correct
7 Correct 10 ms 8680 KB Output is correct
8 Correct 37 ms 9708 KB Output is correct
9 Correct 119 ms 14444 KB Output is correct
10 Incorrect 329 ms 16324 KB Output isn't correct
11 Halted 0 ms 0 KB -