# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
33948 | mohammad_kilani | Split the sequence (APIO14_sequence) | C++14 | 9 ms | 2800 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define oo 2000000000
const int N = 100010;
int n , k , arr[N] , sum[N];
long long solve(vector<int> &v,int j){
if(j == k) return 0;
long long cur = 0 ;
int k = 1;
int idx = 0 ;
int last = 0 ;
for(int i=0;i<v.size();i++){
while(k <= v[i]){
long long f = sum[k] - sum[last];
long long s = sum[v[i]] - sum[k];
long long num = f * s;
if(num > cur){
cur = num;
idx = k;
}
k++;
}
last = v[i];
}
v.push_back(idx);
sort(v.begin(),v.end());
return cur + solve(v,j+1);
}
int main() {
//freopen("in.txt","r",stdin);
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++){
scanf("%d",&arr[i]);
sum[i] = sum[i-1] + arr[i];
}
vector<int> v;
v.push_back(n);
cout << rand()%1234 << endl;
//cout << solve(v,0) << endl;;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |