Submission #1051037

# Submission time Handle Problem Language Result Execution time Memory
1051037 2024-08-09T18:42:23 Z medv Addk (eJOI21_addk) C++14
92 / 100
32 ms 6592 KB
#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;
}

Compilation message

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 time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 3 ms 604 KB Output is correct
8 Correct 2 ms 832 KB Output is correct
9 Correct 3 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1628 KB Output is correct
2 Correct 11 ms 2156 KB Output is correct
3 Correct 13 ms 2908 KB Output is correct
4 Correct 23 ms 4700 KB Output is correct
5 Correct 32 ms 6592 KB Output is correct
6 Correct 31 ms 6480 KB Output is correct
7 Correct 31 ms 6480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 3928 KB Output isn't correct
2 Halted 0 ms 0 KB -