제출 #13359

#제출 시각아이디문제언어결과실행 시간메모리
13359gs14004구경하기 (JOI13_watching)C++14
컴파일 에러
0 ms0 KiB
#include <cstdio> #include <algorithm> using namespace std; int n,p,q,a[2005]; int nxt[2005], nxt2[2005]; char dp[105][105][105]; bool f(int x, int y, int z){ if(y == -1 || z == -1) return 0; if(x == n) return 1; if(~dp[x][y][z]) return dp[x][y][z]; return dp[x][y][z] = f(nxt[x],y-1,z) || f(nxt2[x],y,z-1); } bool trial(int x){ for (int i=0; i<n; i++) { nxt[i] = (int)(lower_bound(a,a+n,a[i]+x) - a); nxt2[i] = (int)(lower_bound(a,a+n,a[i]+2*x) - a); } memset(dp,-1,sizeof(dp)); return f(0,p,q); } int main(){ scanf("%d %d %d",&n,&p,&q); for (int i=0; i<n; i++) { scanf("%d",&a[i]); } p = min(p,n); q = min(q,n); sort(a,a+n); int s = 0, e = 5e8; while (s != e) { int m = (s+e)/2; if(trial(m)) e = m; else s = m+1; } printf("%d",s); }

컴파일 시 표준 에러 (stderr) 메시지

watching.cpp: In function ‘bool f(int, int, int)’:
watching.cpp:14:60: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
     return dp[x][y][z] = f(nxt[x],y-1,z) || f(nxt2[x],y,z-1);
                                                            ^
watching.cpp: In function ‘bool trial(int)’:
watching.cpp:22:28: error: ‘memset’ was not declared in this scope
     memset(dp,-1,sizeof(dp));
                            ^
watching.cpp: In function ‘int main()’:
watching.cpp:27:31: 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:29:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i]);
                          ^