Submission #839509

#TimeUsernameProblemLanguageResultExecution timeMemory
839509XXBabaProBerkayAddk (eJOI21_addk)C++11
0 / 100
112 ms1864 KiB
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second

using ll = long long int;
using pi = pair<int,int>;
using str = string;

const int INF = 1e9 + 7;
const int MOD = 998244353;

int gcd(int a, int b) { return (b==0) ? a : gcd(b, a%b); }
int lcm(int a, int b) { return a*b/gcd(a, b); }

int main()
{
	cin.tie(NULL)->sync_with_stdio(0);

	int N,K; scanf("%d %d",&N,&K);
	vector<int> A(N+1),pref(N+1);
	for(int i=1; i<=N; i++) scanf("%d",&A[i]);
	pref[0] = 0;
	for(int i=1; i<=N; i++) pref[i] = pref[i-1] + A[i];
	int Q; scanf("%d",&Q);
	while(Q--)
	{
		int q; scanf("%d",&q);
		if(q==2)
		{
			int l,r,m; scanf("%d %d %d",&l,&r,&m);
			ll res = 0;
			for(int i=l; i<=r-m+1; i++)
				res += pref[i+m-1] - pref[i-1];
			cout << res << "\n";
		}
		else {
			int x;
			scanf("%d",&x);
		}
	}
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:21:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  int N,K; scanf("%d %d",&N,&K);
      |           ~~~~~^~~~~~~~~~~~~~~
Main.cpp:23:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |  for(int i=1; i<=N; i++) scanf("%d",&A[i]);
      |                          ~~~~~^~~~~~~~~~~~
Main.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  int Q; scanf("%d",&Q);
      |         ~~~~~^~~~~~~~~
Main.cpp:29:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   int q; scanf("%d",&q);
      |          ~~~~~^~~~~~~~~
Main.cpp:32:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |    int l,r,m; scanf("%d %d %d",&l,&r,&m);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~
Main.cpp:40:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |    scanf("%d",&x);
      |    ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...