제출 #312033

#제출 시각아이디문제언어결과실행 시간메모리
312033Rainbowbunny수열 (APIO14_sequence)C++17
0 / 100
9 ms2688 KiB
#include <bits/stdc++.h> #define mp make_pair #define eb emplace_back #define fi first #define se second using namespace std; using cd = complex <double>; const int N = (1 << 20) + 5; const long long INF = 1e9; const int mod = 1e9 + 7;//1e9 + 7;//786433;//998244353; const double Pi = acos(-1); void Fastio() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } int n, k; long long s[100005]; long long dp[100005][2]; signed main() { Fastio(); cin >> n >> k; for(int i = 1; i <= n; i++) { cin >> s[i]; s[i] += s[i - 1]; } for(int i = 1; i <= k; i++) { int pt = i - 1; for(int j = i; j <= n; j++) { while(dp[pt][i & 1 ^ 1] + (s[j] - s[pt]) * s[pt] < dp[pt + 1][i & 1 ^ 1] + (s[j] - s[pt + 1]) * s[pt + 1] and pt + 1 < j) { pt++; } dp[j][i & 1] = dp[pt][i & 1 ^ 1] + s[pt] * (s[j] - s[pt]); } } cout << dp[n][k & 1]; }

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

sequence.cpp: In function 'int main()':
sequence.cpp:39:19: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   39 |    while(dp[pt][i & 1 ^ 1] + (s[j] - s[pt]) * s[pt] < dp[pt + 1][i & 1 ^ 1] + (s[j] - s[pt + 1]) * s[pt + 1] and pt + 1 < j)
      |                 ~~^~~
sequence.cpp:39:68: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   39 |    while(dp[pt][i & 1 ^ 1] + (s[j] - s[pt]) * s[pt] < dp[pt + 1][i & 1 ^ 1] + (s[j] - s[pt + 1]) * s[pt + 1] and pt + 1 < j)
      |                                                                  ~~^~~
sequence.cpp:43:28: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   43 |    dp[j][i & 1] = dp[pt][i & 1 ^ 1] + s[pt] * (s[j] - s[pt]);
      |                          ~~^~~
#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...