제출 #832370

#제출 시각아이디문제언어결과실행 시간메모리
832370vjudge1Addk (eJOI21_addk)C++17
92 / 100
1210 ms5416 KiB
#include<bits/stdc++.h> using namespace std; const int nmax = 1e5+5; int A[nmax]; long long pref[nmax]; int main() { int N,K,Q; cin >> N >> K; pref[0] = 0; for(int i=1; i<=N; i++) { cin >> A[i]; pref[i] = A[i]+pref[i-1]; } cin >> Q; int com,l,r,m; long long sum; while(Q--) { cin >> com; sum = 0; if(com==1) { cin >> m; } else { cin >> l >> r >> m; if(m > (r-l+1)/2) m = (r-l+1)-m+1; for(int i=0; i<m; i++) { sum+=(pref[r-i]-pref[l+i-1]); } cout << sum << endl; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...