結果

問題 No.1307 Rotate and Accumulate
ユーザー NyaanNyaan
提出日時 2020-12-04 00:35:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 395 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 28,032 KB
最終ジャッジ日時 2025-01-16 15:01:34
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |   scanf("%d%d", &N, &Q);
      |   ~~~~~^~~~~~~~~~~~~~~~
main.cpp:6:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |   for (int i = 0; i < N; i++) scanf("%d", a + i);
      |                               ~~~~~^~~~~~~~~~~~~
main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |     scanf("%d", &i);
      |     ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <cstdio>
int a[100000], b[200000];
int main() {
  int N, Q;
  scanf("%d%d", &N, &Q);
  for (int i = 0; i < N; i++) scanf("%d", a + i);
  while (Q--) {
    int i;
    scanf("%d", &i);
    if (i != 0) i = N - i;
    for (int j = 0; j < N; j++) b[i + j] += a[j];
  }
  for (int i = N, j = 0; j < N; i++, j++) {
    if (j) printf(" ");
    printf("%d", b[j] += b[i]);
  }
  printf("\n");
}
0