Submission #640334

# Submission time Handle Problem Language Result Execution time Memory
640334 2022-09-14T09:52:32 Z maks007 Addk (eJOI21_addk) C++14
92 / 100
1470 ms 3068 KB
#include "bits/stdc++.h"
 
// #define int long long
 
signed main () {
	int n, k;
	scanf("%d%d", &n, &k);
	int a[n];
	for(int i = 0; i < n; i ++) scanf("%d", &a[i]);
	long long pref[n];
	pref[0] = a[0];
	for(int i = 1; i < n; i ++) pref[i] = pref[i - 1] + a[i] * 1LL;
	int q;
	scanf("%d", &q);
	while(q --) {
		int type;
		scanf("%d", &type);
		if(type == 1) {
			int kk = k, x;
			while(kk --) scanf("%d", &x);
			continue;
		}
		int l, r, m;
		scanf("%d%d%d", &l, &r, &m);
		l --, r--;
		int cnt = std::min((r-l+1)-m + 1, m);
		long long 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("%d%d", &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("%d", &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("%d", &q);
      |  ~~~~~^~~~~~~~~~
Main.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d", &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("%d", &x);
      |                 ~~~~~^~~~~~~~~~
Main.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   scanf("%d%d%d", &l, &r, &m);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 7 ms 340 KB Output is correct
6 Correct 7 ms 340 KB Output is correct
7 Correct 10 ms 340 KB Output is correct
8 Correct 11 ms 416 KB Output is correct
9 Correct 20 ms 488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 716 KB Output is correct
2 Correct 153 ms 996 KB Output is correct
3 Correct 284 ms 1240 KB Output is correct
4 Correct 856 ms 2284 KB Output is correct
5 Correct 1470 ms 3068 KB Output is correct
6 Correct 1319 ms 3020 KB Output is correct
7 Correct 1114 ms 2848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 230 ms 1456 KB Output isn't correct
2 Halted 0 ms 0 KB -