# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
390113 | ahmet | Split the sequence (APIO14_sequence) | C++14 | 16 ms | 2956 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 zaman cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds "
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define endl '\n'
#define ll long long
#define pb push_back
#define pii pair<ll,ll>
#define mp make_pair
const int mx=2e5+6;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int n,k;cin >> n >> k;
vector <int> a(n+1,0),p(n+1,0);
ref(i,1,n)cin >> a[i];
ref(i,1,n){
p[i]=a[i]+p[i-1];
}
int say=0;
bitset <mx> b;ll ans=0,sum=0,top=0;b[n]=1;
while(say<k){
sum=0;top=0;
int son=1;
priority_queue <pair<int,int> > pq;
for(int i=1;i<=n;++i){
sum+=a[i];top=0;
if(b[i]){
for(int j=son;j<=i;++j){
top+=a[j];
pq.push(mp(top*(sum-top),j));
}
sum=0;
son=i+1;
continue;
}
}
ans+=pq.top().first;
b[pq.top().second]=1;
//cout << pq.top().second << " " << pq.top().first << endl;
++say;
}
cout << ans<<endl;
rep(i,n){
if(b[i])cout<<i<<" ";
}
}
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... |