結果

問題 No.814 ジジ抜き
ユーザー tktk_snsntktk_snsn
提出日時 2021-04-28 22:19:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 429 ms / 3,000 ms
コード長 906 bytes
コンパイル時間 658 ms
コンパイル使用メモリ 90,796 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-07-07 21:19:21
合計ジャッジ時間 8,368 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; }

using ll = long long;
ll K[303030], L[303030], D[303030];
ll two[100];
int n;

bool F(ll x) {
    ll cnt = 0;
    for (int i=0; i<n; ++i) {
        if (x < L[i]) continue;
        cnt += min(K[i], 1 + (x-L[i])/two[D[i]]);
    }
    return cnt%2;
}

int main() {
    two[0] = 1;
    for (int i=1; i<60; ++i) two[i] = two[i-1]*2;

    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> K[i] >> L[i] >> D[i];
    }

    ll l=-1, r=1e18;
    while (r-l>1) {
        ll m = (r+l)/2;
        if (F(m)) r = m;
        else l = m;
    }
    cout << r << endl;
}
0