답안 #476163

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
476163 2021-09-25T07:19:04 Z quackson Addk (eJOI21_addk) C++14
0 / 100
178 ms 1860 KB
#include <bits/stdc++.h>
#pragma GCC diagnostic warning "-std=c++11"
using namespace std;

int main(){
	long long n, k;
	cin >> n >> k;
	
	long long arr[n + 1];
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
	}
	
	long long prefix[n + 1] = {0};
	long long prefix2[n + 1] = {0};
	for(int i = 1; i <= n; i++){
		prefix[i] = prefix[i - 1] + arr[i];
		prefix2[i] = prefix2[i - 1] + arr[i] * i;
	}
	
	int q;
	cin >> q;
	while(q--){
		int oneOrTwo;
		cin >> oneOrTwo;
		
		if(oneOrTwo == 1){
			int smth;
			cin >> smth;
		}
		
		else{
			int l, r, m;
			cin >> l >> r >> m;
			
			m = min(r - l + 2 - m, m);
			
			int a = (prefix2[l + m - 1] - prefix2[l - 1]) - ((l - 1) * (prefix[l + m - 1] - prefix[l - 1]));
			int b = m * (prefix[r - m] - prefix[l + m - 1]);
			int c = ((r + 1) * (prefix[r] - prefix[r - m])) - (prefix2[r] - prefix2[r - m]);
			
			cout << a + b + c << endl;
		}
	}
	return 0;
}

Compilation message

Main.cpp:2:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    2 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 3 ms 204 KB Output is correct
3 Incorrect 5 ms 356 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 70 ms 900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 178 ms 1860 KB Output isn't correct
2 Halted 0 ms 0 KB -