結果

問題 No.3715 Tomorrow is MONDAY!!!!!!
コンテスト
ユーザー HoyHoyCharhang
提出日時 2026-09-18 21:37:05
言語 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  
実行時間 173 ms / 2,000 ms
+ 863µs
コード長 1,195 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,121 ms
コンパイル使用メモリ 331,872 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-09-18 21:37:19
合計ジャッジ時間 7,346 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,g,n) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define eb emplace_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<typename T> using pq = priority_queue<T,vector<T>,greater<T>>;
using P = pair<int,int>;
template<class T>bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,T b){if(b<a){a=b;return 1;}return 0;}

static constexpr ll inf = 1000000000000000000;

int main() {
  int k; ll n;
  cin >> k >> n;
  ll s = 0;
  vector<int> d(k);
  rep(i,0,k) cin >> d[i], s += d[i];
  ll l = 0;
  rep(i,0,k) {
    ll r = l+d[i];
    ll x = dup(r, n);
    ll ans = inf;
    if (x*n+(k-i-1) < s) {
      ans = min(ans, x*n-r+1);
    }
    if (l > 0) {
      ll y = (l-1)/n;
      if (y*n >= i) {
        ans = min(ans, l-y*n);
      }
    }
    if (ans == inf) ans = -1;
    cout << ans << endl;
    l = r;
  }
  return 0;
}
0