Submission #384261

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
3842612021-04-01 04:17:55danielcm585Split the sequence (APIO14_sequence)C++14
100 / 100
1492 ms81900 KiB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> ii;
const int N = 1e5;
const int K = 2e2;
const ll INF = 1e18;
int n, k;
int a[N+2];
int bt[K+2][N+2];
ll sum[N+2];
ll dp[2][N+2];
ll cost(int l, int r) {
return (sum[r]-sum[l-1])*sum[l-1];
}
void compute(int id, int l, int r, int x, int y) {
if (l > r) return;
int mid = (l+r)/2, opt = -1;
dp[id&1][mid] = -INF;
for (int i = x; i <= min(y,mid); i++) {
if (dp[id&1][mid] < dp[id&1^1][i-1]+cost(i,mid)) {
dp[id&1][mid] = dp[id&1^1][i-1]+cost(i,mid);
bt[id][mid] = i-1;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

sequence.cpp: In function 'void compute(int, int, int, int, int)':
sequence.cpp:28:34: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   28 |         if (dp[id&1][mid] < dp[id&1^1][i-1]+cost(i,mid)) {
      |                                ~~^~
sequence.cpp:29:34: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   29 |             dp[id&1][mid] = dp[id&1^1][i-1]+cost(i,mid);
      |                                ~~^~
sequence.cpp: In function 'int main()':
sequence.cpp:51:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for (int i = 1; i < res.size(); 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...