Submission #253890

#TimeUsernameProblemLanguageResultExecution timeMemory
253890ChrisT구경하기 (JOI13_watching)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; int dp[MAXN][MAXN], a[MAXN],p,q,n; int findlast (int cur, int w) { return max(lower_bound(a+1,a+1+n,cur-w+1)-a-1,0); } bool check (int w) { memset(dp,0x3f,sizeof dp); memset(dp[0],0,sizeof dp[0]); for (int i = 1; i <= n; i++) { int lp = findlast(a[i],w), lq = findlast(a[i],w<<1); for (int j = 0; j <= p; j++) { dp[i][j] = dp[lq][j] + 1; if (j) dp[i][j] = min(dp[i][j],dp[lp][j-1]); } } return dp[n][p] <= q; } int main() { int ans=INT_MAX; scanf ("%d %d %d",&n,&p,&q); if (p + q >= n) return !printf ("1\n"); for (int i = 1; i <= n; i++) scanf ("%d",&a[i]); sort(a+1,a+1+n); for (int low = 1, high = 1e9,mid; low <= high;) { if (check(mid = (low + high)>>1)) high = mid-1, ans = mid; else low = mid+1; } printf ("%d\n",ans); return 0; }

Compilation message (stderr)

watching.cpp:5:8: error: 'MAXN' was not declared in this scope
 int dp[MAXN][MAXN], a[MAXN],p,q,n;
        ^~~~
watching.cpp:5:8: note: suggested alternative: 'NAN'
 int dp[MAXN][MAXN], a[MAXN],p,q,n;
        ^~~~
        NAN
watching.cpp:5:14: error: 'MAXN' was not declared in this scope
 int dp[MAXN][MAXN], a[MAXN],p,q,n;
              ^~~~
watching.cpp:5:14: note: suggested alternative: 'NAN'
 int dp[MAXN][MAXN], a[MAXN],p,q,n;
              ^~~~
              NAN
watching.cpp:5:23: error: 'MAXN' was not declared in this scope
 int dp[MAXN][MAXN], a[MAXN],p,q,n;
                       ^~~~
watching.cpp:5:23: note: suggested alternative: 'NAN'
 int dp[MAXN][MAXN], a[MAXN],p,q,n;
                       ^~~~
                       NAN
watching.cpp: In function 'int findlast(int, int)':
watching.cpp:7:28: error: 'a' was not declared in this scope
     return max(lower_bound(a+1,a+1+n,cur-w+1)-a-1,0);
                            ^
watching.cpp: In function 'bool check(int)':
watching.cpp:10:12: error: 'dp' was not declared in this scope
     memset(dp,0x3f,sizeof dp); memset(dp[0],0,sizeof dp[0]);
            ^~
watching.cpp:10:12: note: suggested alternative: 'p'
     memset(dp,0x3f,sizeof dp); memset(dp[0],0,sizeof dp[0]);
            ^~
            p
watching.cpp:12:25: error: 'a' was not declared in this scope
       int lp = findlast(a[i],w), lq = findlast(a[i],w<<1);
                         ^
watching.cpp:14:27: error: 'lq' was not declared in this scope
             dp[i][j] = dp[lq][j] + 1;
                           ^~
watching.cpp:14:27: note: suggested alternative: 'lp'
             dp[i][j] = dp[lq][j] + 1;
                           ^~
                           lp
watching.cpp: In function 'int main()':
watching.cpp:24:47: error: 'a' was not declared in this scope
     for (int i = 1; i <= n; i++) scanf ("%d",&a[i]);
                                               ^
watching.cpp:25:10: error: 'a' was not declared in this scope
     sort(a+1,a+1+n);
          ^
watching.cpp:22:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d %d",&n,&p,&q);
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~