답안 #1030385

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1030385 2024-07-22T04:17:25 Z vannnnnnnn Addk (eJOI21_addk) C++14
92 / 100
69 ms 7440 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[100005], pre[100005], suf[100005], nom[100005];
int main()
{
	ll n, k;
	scanf("%lld %lld", &n, &k);
	for(int i=1; i<=n; i++)
	{
		scanf("%d", &a[i]);
		pre[i]=pre[i-1]+(i*a[i]);
		nom[i]=nom[i-1]+a[i];
	}
	for(int i=n; i>=1; i--)suf[i]=suf[i+1]+((n-i+1)*a[i]);
	int q;
	scanf("%d", &q);
	while(q--)
	{
		int que;
		scanf("%d", &que);
		if(que==1)
		{
			int blog;
			scanf("%d", &blog);
		}
		else
		{
			int l,r, m;
			scanf("%d %d %d", &l, &r, &m);
			ll len=r-l+1-m;
			ll ans=pre[l+len]-pre[l-1];
			ans+=(suf[r-len]-suf[r+1]);
			ans+=((nom[r-len-1]-nom[l+len])*(len+1));
			ans-=((nom[l+len]-nom[l-1])*(l-1));
			ans-=((nom[r]-nom[r-len-1])*(n-r));
			printf("%lld\n", ans);
		}
	}
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:11:11: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   11 |   scanf("%d", &a[i]);
      |          ~^   ~~~~~
      |           |   |
      |           |   long long int*
      |           int*
      |          %lld
Main.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  scanf("%lld %lld", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
Main.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%d", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~
Main.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d", &q);
      |  ~~~~~^~~~~~~~~~
Main.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%d", &que);
      |   ~~~~~^~~~~~~~~~~~
Main.cpp:25:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |    scanf("%d", &blog);
      |    ~~~~~^~~~~~~~~~~~~
Main.cpp:30:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |    scanf("%d %d %d", &l, &r, &m);
      |    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 3 ms 868 KB Output is correct
9 Correct 4 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1628 KB Output is correct
2 Correct 12 ms 2392 KB Output is correct
3 Correct 16 ms 3164 KB Output is correct
4 Correct 28 ms 5208 KB Output is correct
5 Correct 40 ms 7440 KB Output is correct
6 Correct 45 ms 7068 KB Output is correct
7 Correct 69 ms 7184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 4276 KB Output isn't correct
2 Halted 0 ms 0 KB -