結果

問題 No.3472 ジャッジキューの待ち時間クエリ
コンテスト
ユーザー tnakao0123
提出日時 2026-03-07 17:33:47
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 695 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 284 ms
コンパイル使用メモリ 53,920 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-07 17:33:50
合計ジャッジ時間 2,251 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
サンプル 10 点 AC * 3
Small 30 点 AC * 7
Large 60 点 AC * 7
合計 100 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 3472.cc:  No.3472 繧ク繝」繝・ず繧ュ繝・繝シ縺ョ蠕・■譎る俣繧ッ繧ィ繝ェ - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

using ll = long long;

/* global variables */

int ts[MAX_N];
ll tss[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int n, qn;
  scanf("%d%d", &n, &qn);
  for (int i = 0; i < n; i++) scanf("%d", ts + i);

  for (int i = 0; i < n; i++) tss[i + 1] = tss[i] + ts[i];

  while (qn--) {
    ll x;
    scanf("%lld", &x);

    int i = upper_bound(tss, tss + n + 1, x) - tss - 1;
    printf("%d\n", i);
  }
  
  return 0;
}

0