結果

問題 No.3389 k-Days Later
コンテスト
ユーザー t98slider
提出日時 2025-11-28 21:31:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 1,901 ms
コンパイル使用メモリ 198,356 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-11-28 21:31:34
合計ジャッジ時間 10,630 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n), sv(n + 1);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sv[i + 1] = sv[i] + a[i];
    }
    int Q;
    cin >> Q;
    while(Q--){
        ll y, m, d, k;
        cin >> y >> m >> d >> k;
        m--, d--;
        __int128 c = __int128(y) * sv[n] + sv[m] + d + k;
        ll y2 = c / sv[n];
        c -= y2 * __int128(sv[n]);
        ll m2 = (upper_bound(sv.begin(), sv.end(), c) - sv.begin()) - 1;
        ll d2 = c - sv[m2];
        m2++, d2++;
        cout << y2 << ' ' << m2 << ' ' << d2 << '\n';
    }
}
0