답안 #980049

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
980049 2024-05-11T20:09:10 Z TheFuturoma Addk (eJOI21_addk) C++14
0 / 100
117 ms 984 KB
#include <cmath>
#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>

using namespace std;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	
	int n, k;
    cin>>n>>k;
    if (k > 1) {
        return 0;
    }
    vector<ll> arr(n);
    vector<ll> prefix(1, 0);
    for (int i = 0; i < n; i++) {
        cin>>arr[i];
        prefix.push_back(prefix.back() + arr[i]);
    }
    int q;
    cin>>q;
    for (int test = 0; test < q; test++) {
        int t;
        cin>>t;
        if (t == 1) {
            int curr;
            cin>>curr;
            continue;
        }
        int left, right, m;
        cin>>left>>right>>m;
        left--;
        right--;
        if (m == right - left + 1) {
            cout << prefix[right + 1] - prefix[left] << endl;
        }
        int left_part = min(left + m, right - m + 1);
        int right_part = max(right - m, left + m - 1);
        ll res = 0;
        for (int i = left; i < left_part; i++) {
            res += arr[i] * (i - left + 1);
        }
        for (int i = right; i > right_part; i--) {
            res += arr[i] * (right - i + 1);
        }
        // cout << right_part << " " << left_part << endl;
        res += (prefix[right_part + 1] - prefix[left_part]) * min(m, left_part - left + 1);
        cout << res << endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 117 ms 984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -