0_0_19991897_18652.cpp:1:909: fatal error: GCC4.9.2/x86_64-w64-mingw32/include/c++/bits/stdc++.h>usin: Invalid argument
#include<bits/stdc++.h>using namespace std;const int maxn = 500050;int a[maxn], sum[maxn], dp[maxn];int que[maxn], st, ed;int N, M;int GETUP(int i, int j){ return dp[j] + sum[j] * sum[j] - dp[i] - sum[i] * sum[i];}int GETDOWN(int i, int j){ return 2 * (sum[j] - sum[i]);}int GETDP(int i, int j){ dp[j] = dp[i] + (sum[j] - sum[i]) * (sum[j] - sum[i]) + M;}int main (){ while(~scanf("%d%d", &N, &M)) { for(int i = 1; i <= N; i++) { scanf("%d", &a[i]); sum[i] = sum[i - 1] + a[i]; } st = 0, ed = 1; que[st] = 0; for(int i = 1; i <= N; i++) { while(st + 1 < ed && GETUP(que[st], que[st + 1]) < sum[i]*GETDOWN(que[st], que[st + 1])) st++; GETDP(que[st], i); while(st+1<ed&&(GETUP(que[ed-2],que[ed-1])*GETDOWN(que[ed-1],i))>(GETUP(que[ed-1],i)*GETDOWN(que[ed-2],que[ed-1]))) ed--; que[ed++] = i; } printf("%d\n",dp[N]); } return 0;}
^
compilation terminated.
|