답안 #637815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
637815 2022-09-03T10:57:59 Z ksu2009en Addk (eJOI21_addk) C++17
92 / 100
1238 ms 5804 KB
#pragma GCC optimize("O3")
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>

using namespace std;
typedef long long ll;
#define endl '\n'

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, k;
    cin >> n >> k;
    
    vector<ll>a(n + 1);

    for(int i = 1; i <= n; i++)
        cin >> a[i];
    
    vector<ll>pref(n + 1);
    
    for(int i = 1; i <= n; i++)
        pref[i] = pref[i - 1] + a[i];
    
    ll q;
    cin >> q;
    
    while(q--){
        ll type;
        cin >> type;
        
        if(type == 1){
            ll p;
            for(int i = 0; i < k; i++)
                cin >> p;
        }
        else{
            ll l, r, m;
            cin >> l >> r >> m;
            
            ll cnt = min(m, (r - l + 1) - m + 1);
           // cout << cnt << endl;
            
            ll ans = 0;
            
            while(cnt > 0){
                ans += pref[r] - pref[l - 1];
                l++, r--;
                
                cnt--;
            }
            cout << ans << endl;
        }
    }
    
    return 0;
}
/*
 3 1
 3 4 5
 1 2 90
 
 */
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 5 ms 464 KB Output is correct
6 Correct 6 ms 468 KB Output is correct
7 Correct 9 ms 596 KB Output is correct
8 Correct 11 ms 596 KB Output is correct
9 Correct 22 ms 796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 1356 KB Output is correct
2 Correct 134 ms 1936 KB Output is correct
3 Correct 247 ms 2524 KB Output is correct
4 Correct 779 ms 4160 KB Output is correct
5 Correct 1238 ms 5804 KB Output is correct
6 Correct 1123 ms 5628 KB Output is correct
7 Correct 955 ms 5540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 191 ms 3508 KB Output isn't correct
2 Halted 0 ms 0 KB -