제출 #709828

#제출 시각아이디문제언어결과실행 시간메모리
709828lern수열 (APIO14_sequence)C++11
0 / 100
16 ms728 KiB
#include <bits/stdc++.h> using namespace std; int main() { std::vector<int> myvector; int 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 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...