Submission #839505

#TimeUsernameProblemLanguageResultExecution timeMemory
839505XXBabaProBerkayAddk (eJOI21_addk)C++11
0 / 100
2064 ms1020 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);
	for(int i=1; i<=N; i++) scanf("%d",&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++)
				for(int j=0; j<m; j++)
					res += A[i+j];
			printf("%d\n",res);
		}
		else {
			int x;
			scanf("%d",&x);
		}
	}
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:35:13: warning: format '%d' expects argument of type 'int', but argument 2 has type 'll' {aka 'long long int'} [-Wformat=]
   35 |    printf("%d\n",res);
      |            ~^    ~~~
      |             |    |
      |             int  ll {aka long long int}
      |            %lld
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:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  int Q; scanf("%d",&Q);
      |         ~~~~~^~~~~~~~~
Main.cpp:27:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   int q; scanf("%d",&q);
      |          ~~~~~^~~~~~~~~
Main.cpp:30:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |    int l,r,m; scanf("%d %d %d",&l,&r,&m);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~
Main.cpp:39:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |    scanf("%d",&x);
      |    ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...