답안 #1071732

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071732 2024-08-23T10:37:17 Z vjudge1 Addk (eJOI21_addk) C++17
36 / 100
2000 ms 3924 KB
#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;

const int N = 100002;
ll n, K;
int a[N], q;
short int op;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	cin >> n >> K;
	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];

	q; cin >> q;
	for (int tc = 1; tc <= q; ++tc) {
		cin >> op;
		if (op == 1) {
			int x; cin >> x;
			continue;
		} 
		else {
			int l, r, m;
			cin >> l >> r >> m;

			ll sum = 0;
			int tl = l + m - 1;
			while (tl <= r) {
				sum += pref[tl] - pref[tl-m];
				tl++;
			}
				

			cout << sum << '\n';
		}
	}
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:23:2: warning: statement has no effect [-Wunused-value]
   23 |  q; cin >> q;
      |  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 5 ms 604 KB Output is correct
6 Correct 8 ms 668 KB Output is correct
7 Correct 11 ms 720 KB Output is correct
8 Correct 14 ms 724 KB Output is correct
9 Correct 36 ms 912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 788 KB Output is correct
2 Correct 283 ms 1900 KB Output is correct
3 Correct 463 ms 2384 KB Output is correct
4 Correct 1632 ms 3844 KB Output is correct
5 Execution timed out 2047 ms 3924 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -