답안 #476167

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
476167 2021-09-25T07:27:15 Z quackson Addk (eJOI21_addk) C++11
0 / 100
170 ms 1880 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];
	long long prefix[n + 1] = {0};
	long long prefix2[n + 1] = {0};
	for(int i = 1; i <= n; i++){
		cin >> arr[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]) - (prefix[l + m - 1] - prefix[l - 1]) * (l - 1);
			int b = (prefix[r - m] - prefix[l + m - 1]) * m;
			int c = (prefix[r] - prefix[r - m]) * (r + 1) - (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 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 63 ms 968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 170 ms 1880 KB Output isn't correct
2 Halted 0 ms 0 KB -