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;
int main()
{
std::vector<int> myvector;
long n,k,cem=0,ij=0,cem1=0;
cin>>n>>k;
int a[n];
for(int i=0 ;i<n ; i++){
cin>>a[i];
}
if(n%2!=0){
for(int i=1 ;i<n ; i++){
cem+=a[i];
}
cem*=a[0];
ij=1;
myvector.push_back(ij);
}
else{
for(int i=2 ;i<n ; i++){
cem+=a[i];
}
cem*=(a[0]+a[1]);
ij=2;
myvector.push_back(ij);
}
for(int i=0 ;i<k-1 ; i++){
for(int j=ij+2 ; j<n ; j++){
cem1+=a[j];
}
cem+=cem1*(a[ij]+a[ij+1]);
ij+=2;
myvector.push_back(ij);
cem1=0;
}
cout<<cem<<endl;
for(int i=0 ;i<k ;i++){
cout<<myvector[i]<<" ";
}
return 0;
}
# | 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... |