제출 #7610

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
76102014-08-12 13:50:21hongjun7수열 (APIO14_sequence)C++98
컴파일 에러
0 ms0 KiB
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define MK 202
#define MN 100002
int N, K, i, j, k, X[MN], _k = 1, best[MK][MN], s[MN], b;
long long d[2][MN], f[MN], S[MN];
bool ok(int z) {
int x = s[b-1], y = s[b];
return (f[y]-f[x])*(S[y]-S[z]) >= (f[z]-f[y]) *(S[x]-S[y]);
}
int main() {
int x;
scanf("%d%d",&N,&K);
for (i = 1; i <= N; i++) {
scanf("%d", &X[i]);
S[i] = S[i-1] + X[i];
}
for (i = 0; i <= N; i++) d[0][i] = -1;
for (k = 2; k <= K+1; k++) {
_k = k&1;
for (i = 0; i <= N; i++) d[_k][i] = 0;
b = -1; x = 1;
s[++b] = 0; s[++b] = 1;
for (i = 0; i <= N; i++) f[i] = d[!(_k)][i]-S[i]*S[i];
for (i = 2; i <= N; i++) {
if (x > b) x = b;
while (x < b && (f[s[x]]-f[s[x+1]]) <= (S[s[x+1]] - S[s[x]])*S[i]) x++;
d[_k][i] = f[s[x]]+S[s[x]]*S[i];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

sequence.cpp: In function 'int main()':
sequence.cpp:40:3: error: 'res' was not declared in this scope
sequence.cpp:42:10: error: 'res' was not declared in this scope
sequence.cpp:15:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
sequence.cpp:17:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]