結果

問題 No.3715 Tomorrow is MONDAY!!!!!!
コンテスト
ユーザー ぽえ
提出日時 2026-09-18 19:12:27
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 61 ms / 2,000 ms
+ 821µs
コード長 564 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,095 ms
コンパイル使用メモリ 332,744 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-09-18 20:52:06
合計ジャッジ時間 5,961 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
    int k; ll n; cin >> k >> n;
    vector<ll> d(k);
    ll s = 0;
    for (auto& i : d) { cin >> i;  s += i; }
    
    ll l=0, r=0;
    for (int i=0; i<k; i++, l=r) {
        ll ans = numeric_limits<ll>::max();
        ll x = l%n;
        if (x == 0) x = n;
        if (x <= l-i) ans = min(ans, x);
        r = l+d[i];
        ll y = n-(r-1)%n;
        if (y <= s-r-(k-i-1)) ans = min(ans, y);
        
        cout << (ans==numeric_limits<ll>::max() ? -1 : ans) << '\n';
    }
}
0