답안 #640094

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
640094 2022-09-13T14:55:12 Z maks007 Addk (eJOI21_addk) C++14
92 / 100
1122 ms 5976 KB
#include "bits/stdc++.h"

#define int long long

signed main () {
	int n, k;
	scanf("%lld%lld", &n, &k);
	int a[n];
	for(int i = 0; i < n; i ++) scanf("%lld", &a[i]);
	int pref[n];
	pref[0] = a[0];
	for(int i = 1; i < n; i ++) pref[i] = pref[i - 1] + a[i];
	int q;
	scanf("%lld", &q);
	while(q --) {
		int type;
		scanf("%lld", &type);
		if(type == 1) {
			int kk = k, x;
			while(kk --) scanf("%lld", &x);
			continue;
		}
		int l, r, m;
		scanf("%lld%lld%lld", &l, &r, &m);
		l --, r--;
		int cnt = std::min((r-l+1)-m + 1, m);
		int ans = 0;
		while(cnt --) {
			ans += pref[r] - (!l ? 0: pref[l - 1]);
			r --, l ++;
		}
		printf("%lld\n", ans);
		
	}
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  scanf("%lld%lld", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:9:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  for(int i = 0; i < n; i ++) scanf("%lld", &a[i]);
      |                              ~~~~~^~~~~~~~~~~~~~~
Main.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%lld", &q);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%lld", &type);
      |   ~~~~~^~~~~~~~~~~~~~~
Main.cpp:20:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |    while(kk --) scanf("%lld", &x);
      |                 ~~~~~^~~~~~~~~~~~
Main.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   scanf("%lld%lld%lld", &l, &r, &m);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 3 ms 436 KB Output is correct
5 Correct 5 ms 468 KB Output is correct
6 Correct 6 ms 468 KB Output is correct
7 Correct 7 ms 596 KB Output is correct
8 Correct 9 ms 596 KB Output is correct
9 Correct 19 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 1240 KB Output is correct
2 Correct 125 ms 1884 KB Output is correct
3 Correct 215 ms 2432 KB Output is correct
4 Correct 717 ms 4188 KB Output is correct
5 Correct 1122 ms 5976 KB Output is correct
6 Correct 996 ms 5548 KB Output is correct
7 Correct 831 ms 5632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 160 ms 3228 KB Output isn't correct
2 Halted 0 ms 0 KB -