結果

問題 No.702 中央値を求めよ LIMITED
ユーザー donkorin_donkorin_
提出日時 2018-09-11 14:26:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 625 ms / 5,000 ms
コード長 1,400 bytes
コンパイル時間 1,437 ms
コンパイル使用メモリ 164,084 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-14 21:45:31
合計ジャッジ時間 19,544 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 606 ms
4,380 KB
testcase_01 AC 604 ms
4,376 KB
testcase_02 AC 623 ms
4,380 KB
testcase_03 AC 606 ms
4,376 KB
testcase_04 AC 607 ms
4,380 KB
testcase_05 AC 605 ms
4,380 KB
testcase_06 AC 625 ms
4,380 KB
testcase_07 AC 606 ms
4,380 KB
testcase_08 AC 606 ms
4,380 KB
testcase_09 AC 605 ms
4,376 KB
testcase_10 AC 604 ms
4,376 KB
testcase_11 AC 605 ms
4,380 KB
testcase_12 AC 605 ms
4,380 KB
testcase_13 AC 605 ms
4,376 KB
testcase_14 AC 604 ms
4,380 KB
testcase_15 AC 606 ms
4,380 KB
testcase_16 AC 606 ms
4,376 KB
testcase_17 AC 606 ms
4,376 KB
testcase_18 AC 604 ms
4,380 KB
testcase_19 AC 623 ms
4,376 KB
testcase_20 AC 604 ms
4,376 KB
testcase_21 AC 605 ms
4,376 KB
testcase_22 AC 623 ms
4,380 KB
testcase_23 AC 623 ms
4,376 KB
testcase_24 AC 605 ms
4,376 KB
testcase_25 AC 607 ms
4,376 KB
testcase_26 AC 606 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

uint32_t x = 0, y = 1, z = 2, w = 3;
int64_t seed;
uint32_t generate() { 
    uint32_t t = (x^(x<<11));
    x = y;
    y = z;
    z = w;
    w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); 
    return (ll)w;
}

ll counting(ll t) {
    x = seed, y = 1, z = 2, w = 3;
    ll res = 0;
    rep(i, 0, 10000001) if (generate() <= t) res++;
    return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> seed; 
    x = seed;
    ll l = 0, r = 1e10+1LL;
    while (r - l != 1) {
        ll mid = (r + l) / 2;
        if (5000001 <= counting(mid)) r = mid;
        else l = mid;
    }
    cout << r << endl;
    return 0;
}
0