Submission #472919

# Submission time Handle Problem Language Result Execution time Memory
472919 2021-09-14T14:45:07 Z fuad27 Addk (eJOI21_addk) C++17
0 / 100
1018 ms 3004 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main () {
	int n, k;
	cin >> n >> k;
	int arr[n];
	for(int i = 0;i<n;i++) {
		cin >> arr[i];
	}
	int q;
	cin >> q;
	while(q--) {
		int k, ans = 0;
		cin >> k;
		if(k == 1) {
			int d;
			cin >> d;
		}
		else {
			int ans = 0;
			int l, r, m;
			cin >> l >> r >> m;
			l--;
			m = min(r-l-m+2, m);
			for(int i = l;i<r;i++) {
				ans += min(m, min(i-l+1, r-i))*arr[i];
			}
			cout<<ans<<endl;
		}
	}
}

Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:14:10: warning: unused variable 'ans' [-Wunused-variable]
   14 |   int k, ans = 0;
      |          ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 541 ms 996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1018 ms 3004 KB Output isn't correct
2 Halted 0 ms 0 KB -