제출 #1051037

#제출 시각아이디문제언어결과실행 시간메모리
1051037medvAddk (eJOI21_addk)C++14
92 / 100
32 ms6592 KiB
#include <cstdio>
#include <vector>
using namespace std;

int q, i, n, k, l, r, m, typ, ix;
long long res, s1, s2, s3;
vector<long long> a, b, c;

int main()
{
  scanf("%d %d", &n, &k);
  a.resize(n + 1);
  for (i = 1; i <= n; i++)
    scanf("%lld", &a[i]);

  b.resize(n + 1);
  b[0] = a[0];
  for (i = 1; i <= n; i++)
    b[i] = b[i - 1] + a[i];

  c.resize(n + 1);
  c[0] = a[0];
  for (i = 1; i <= n; i++)
    c[i] = c[i - 1] + i * a[i];

  scanf("%d", &q);
  while (q--)
  {
    scanf("%d", &typ);
    if (typ == 1)
    {
      for (i = 0; i < k; i++)
        scanf("%d", &ix);
    }
    else
    {
      scanf("%d %d %d", &l, &r, &m);
      s1 = c[l + m - 2] - c[l - 1] - (l - 1) * (b[l + m - 2] - b[l - 1]);
      s2 = m * (b[r - m + 1] - b[l + m - 2]);
      s3 = (r + 1) * (b[r] - b[r - m + 1]) - (c[r] - c[r - m + 1]);
      res = s1 + s2 + s3;
      printf("%lld\n", res);
    }
  }
  return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%d %d", &n, &k);
      |   ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%lld", &a[i]);
      |     ~~~~~^~~~~~~~~~~~~~~
Main.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%d", &q);
      |   ~~~~~^~~~~~~~~~
Main.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     scanf("%d", &typ);
      |     ~~~~~^~~~~~~~~~~~
Main.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         scanf("%d", &ix);
      |         ~~~~~^~~~~~~~~~~
Main.cpp:37:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |       scanf("%d %d %d", &l, &r, &m);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...