結果

問題 No.3067 +10 Seconds Clock
ユーザー tnakao0123
提出日時 2025-03-23 17:35:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 830 bytes
コンパイル時間 518 ms
コンパイル使用メモリ 40,444 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-23 17:35:14
合計ジャッジ時間 2,580 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |   scanf("%d%d", &n, &t);
      |   ~~~~~^~~~~~~~~~~~~~~~
main.cpp:28:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |   for (int i = 1; i < n; i++) scanf("%d", ts + i);
      |                               ~~~~~^~~~~~~~~~~~~~
main.cpp:30:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |   scanf("%d", &k);
      |   ~~~~~^~~~~~~~~~
main.cpp:31:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |   for (int i = 0; i < k; i++) scanf("%d", xs + i), xs[i]--;
      |                               ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 3067.cc:  No.3067 &#43;10 Seconds Clock - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

int ts[MAX_N], xs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, t;
  scanf("%d%d", &n, &t);
  for (int i = 1; i < n; i++) scanf("%d", ts + i);
  int k;
  scanf("%d", &k);
  for (int i = 0; i < k; i++) scanf("%d", xs + i), xs[i]--;

  int cnt = 0, xc = 0;
  for (int i = 0, j = 0; i < n; i++) {
    t -= ts[i];
    //printf(" i=%d, t=%d, xc=%d\n", i, t, xc);

    if (t <= 0) {
      int d = -t / 10 + 1;
      if (d > xc) { puts("-1"); return 0; }
      t += d * 10;
      cnt += d, xc -= d;
    }

    if (j < k && i == xs[j]) xc++, j++;
  }

  printf("%d\n", cnt);
  
  return 0;
}
0