제출 #1022460

#제출 시각아이디문제언어결과실행 시간메모리
1022460daffuwu수열 (APIO14_sequence)C++14
39 / 100
2035 ms8612 KiB
#include <bits/stdc++.h> using namespace std; #define fr first #define sc second mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, k, opt[100002][202]; long long ps[100069], dp[100069][2], val; int main() { int i, j, c; scanf("%d%d", &n, &k); k++; for (i=1; i<=n; i++) { scanf("%lld", ps+i); ps[i] += ps[i-1]; dp[i][0] = -1e15; } for (c=1; c<=k; c++) { dp[0][c%2] = -1e15; for (i=1; i<=n; i++) { dp[i][c%2] = 0; for (j=i-1; j>=0; j--) { val = dp[j][(c+1)%2]+(ps[i]-ps[j])*ps[j]; if (val>dp[i][c%2]) { dp[i][c%2] = val; opt[i][c] = j; } } } } printf("%lld\n", dp[n][k%2]); for (i=n, c=k; c>=2; i=opt[i][c], c--) { printf("%d ", opt[i][c]); } printf("\n"); }

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

sequence.cpp: In function 'int main()':
sequence.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d%d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~
sequence.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%lld", ps+i);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...