답안 #540391

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
540391 2022-03-20T09:25:13 Z krit3379 구경하기 (JOI13_watching) Java 11
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define N 2005

long long a[N],dp[N][N],l,r,mid,w,w2,ans;

int main(){
    int n,i,j,p,q;
    scanf("%d %d %d",&n,&p,&q);
    for(i=1;i<=n;i++)scanf("%lld",&a[i]);
    a[n+1]=1e18;
    sort(a+1,a+n+1);
    if(p+q>=n){printf("1");return 0;}
    l=1,r=1e9;
    while(l<=r){
        mid=(l+r)/2;
        for(i=0;i<=p;i++)for(j=0;j<=q;j++)dp[i][j]=0;
        dp[0][0]=1;
        w=mid-1;
        w2=mid*2-1;
        for(i=1;i<=p;i++)dp[i][0]=upper_bound(a+1,a+n+1,a[dp[i-1][0]]+w)-a;
        for(i=1;i<=q;i++)dp[0][i]=upper_bound(a+1,a+n+1,a[dp[0][i-1]]+w2)-a;
        for(i=1;i<=p;i++){
            for(j=1;j<=q;j++){
                int pos1=upper_bound(a+1,a+n+1,a[dp[i][j-1]]+w2)-a;
                int pos2=upper_bound(a+1,a+n+1,a[dp[i-1][j]]+w)-a;
                dp[i][j]=max(pos1,pos2);
            }
        }
        if(dp[p][q]==n+1)ans=mid,r=mid-1;
        else l=mid+1;
    }
    printf("%lld",ans);
    return 0;
}

Compilation message

watching.java:1: error: illegal character: '#'
#include<bits/stdc++.h>
^
watching.java:1: error: class, interface, or enum expected
#include<bits/stdc++.h>
        ^
watching.java:3: error: illegal character: '#'
#define N 2005
^
watching.java:3: error: class, interface, or enum expected
#define N 2005
        ^
watching.java:7: error: class, interface, or enum expected
int main(){
^
watching.java:9: error: class, interface, or enum expected
    scanf("%d %d %d",&n,&p,&q);
    ^
watching.java:10: error: class, interface, or enum expected
    for(i=1;i<=n;i++)scanf("%lld",&a[i]);
    ^
watching.java:10: error: class, interface, or enum expected
    for(i=1;i<=n;i++)scanf("%lld",&a[i]);
            ^
watching.java:10: error: class, interface, or enum expected
    for(i=1;i<=n;i++)scanf("%lld",&a[i]);
                 ^
watching.java:11: error: class, interface, or enum expected
    a[n+1]=1e18;
    ^
watching.java:12: error: class, interface, or enum expected
    sort(a+1,a+n+1);
    ^
watching.java:13: error: class, interface, or enum expected
    if(p+q>=n){printf("1");return 0;}
    ^
watching.java:13: error: class, interface, or enum expected
    if(p+q>=n){printf("1");return 0;}
                           ^
watching.java:13: error: class, interface, or enum expected
    if(p+q>=n){printf("1");return 0;}
                                    ^
watching.java:15: error: class, interface, or enum expected
    while(l<=r){
    ^
watching.java:17: error: class, interface, or enum expected
        for(i=0;i<=p;i++)for(j=0;j<=q;j++)dp[i][j]=0;
        ^
watching.java:17: error: class, interface, or enum expected
        for(i=0;i<=p;i++)for(j=0;j<=q;j++)dp[i][j]=0;
                ^
watching.java:17: error: class, interface, or enum expected
        for(i=0;i<=p;i++)for(j=0;j<=q;j++)dp[i][j]=0;
                     ^
watching.java:17: error: class, interface, or enum expected
        for(i=0;i<=p;i++)for(j=0;j<=q;j++)dp[i][j]=0;
                                 ^
watching.java:17: error: class, interface, or enum expected
        for(i=0;i<=p;i++)for(j=0;j<=q;j++)dp[i][j]=0;
                                      ^
watching.java:18: error: class, interface, or enum expected
        dp[0][0]=1;
        ^
watching.java:19: error: class, interface, or enum expected
        w=mid-1;
        ^
watching.java:20: error: class, interface, or enum expected
        w2=mid*2-1;
        ^
watching.java:21: error: class, interface, or enum expected
        for(i=1;i<=p;i++)dp[i][0]=upper_bound(a+1,a+n+1,a[dp[i-1][0]]+w)-a;
        ^
watching.java:21: error: class, interface, or enum expected
        for(i=1;i<=p;i++)dp[i][0]=upper_bound(a+1,a+n+1,a[dp[i-1][0]]+w)-a;
                ^
watching.java:21: error: class, interface, or enum expected
        for(i=1;i<=p;i++)dp[i][0]=upper_bound(a+1,a+n+1,a[dp[i-1][0]]+w)-a;
                     ^
watching.java:22: error: class, interface, or enum expected
        for(i=1;i<=q;i++)dp[0][i]=upper_bound(a+1,a+n+1,a[dp[0][i-1]]+w2)-a;
        ^
watching.java:22: error: class, interface, or enum expected
        for(i=1;i<=q;i++)dp[0][i]=upper_bound(a+1,a+n+1,a[dp[0][i-1]]+w2)-a;
                ^
watching.java:22: error: class, interface, or enum expected
        for(i=1;i<=q;i++)dp[0][i]=upper_bound(a+1,a+n+1,a[dp[0][i-1]]+w2)-a;
                     ^
watching.java:23: error: class, interface, or enum expected
        for(i=1;i<=p;i++){
        ^
watching.java:23: error: class, interface, or enum expected
        for(i=1;i<=p;i++){
                ^
watching.java:23: error: class, interface, or enum expected
        for(i=1;i<=p;i++){
                     ^
watching.java:24: error: class, interface, or enum expected
            for(j=1;j<=q;j++){
                    ^
watching.java:24: error: class, interface, or enum expected
            for(j=1;j<=q;j++){
                         ^
watching.java:26: error: class, interface, or enum expected
                int pos2=upper_bound(a+1,a+n+1,a[dp[i-1][j]]+w)-a;
                ^
watching.java:27: error: class, interface, or enum expected
                dp[i][j]=max(pos1,pos2);
                ^
watching.java:28: error: class, interface, or enum expected
            }
            ^
watching.java:31: error: class, interface, or enum expected
        else l=mid+1;
        ^
watching.java:32: error: class, interface, or enum expected
    }
    ^
watching.java:34: error: class, interface, or enum expected
    return 0;
    ^
watching.java:35: error: class, interface, or enum expected
}
^
41 errors