結果

問題 No.649 ここでちょっとQK!
ユーザー ElnathGeekElnathGeek
提出日時 2018-10-18 20:10:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,371 bytes
コンパイル時間 1,008 ms
コンパイル使用メモリ 117,596 KB
実行使用メモリ 5,788 KB
最終ジャッジ日時 2024-04-24 15:41:30
合計ジャッジ時間 5,753 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 305 ms
5,376 KB
testcase_04 AC 169 ms
5,788 KB
testcase_05 AC 156 ms
5,728 KB
testcase_06 AC 165 ms
5,448 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 88 ms
5,376 KB
testcase_13 AC 84 ms
5,376 KB
testcase_14 AC 83 ms
5,376 KB
testcase_15 AC 91 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 99 ms
5,376 KB
testcase_18 AC 111 ms
5,376 KB
testcase_19 AC 117 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 141 ms
5,376 KB
testcase_23 AC 151 ms
5,376 KB
testcase_24 AC 161 ms
5,376 KB
testcase_25 AC 176 ms
5,376 KB
testcase_26 AC 181 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 WA -
testcase_30 AC 54 ms
5,376 KB
testcase_31 AC 56 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘ll gcd(ll, ll)’:
main.cpp:62:12: warning: control reaches end of non-void function [-Wreturn-type]
   62 |         gcd(b,d);
      |         ~~~^~~~~

ソースコード

diff #

#define _USE_MATH_DEFINES    
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define quickIO()   {cin.tie(0);    cout.sync_with_stdio(false);}
#define rep(i,n)    for(ll i=0; i<(ll)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define fcout cout << fixed << setprecision(10) 
const ll inf = 1e18;
const ll mod = 1e9 +7;
     
ld sqrtld(ld x){
    ld left = 0, right = x;
    rep(i, 100){
        ld mid = (left + right)/2;
        if (mid*mid <= x)   left =mid;
        else    right = mid;
    }
    return left;
}

ll gcd(ll a, ll b){
    if(b>a){
        ll c =b; b=a;   a=c;
    }
    ll d = a%b;
    if(d==0){
        return b;
    }else if(d==1){
        return 1;
    }else{
        gcd(b,d);
    }
}


int main (){
    int q,k;
    cin >> q >> k;
    int n=0;
    priority_queue<ll> maxpq;
    priority_queue<ll, vector<ll>, greater<ll> > minpq;

    rep(i,q){
        ll w;  cin >> w;
        if(w==1){
            ll v;  cin >> v;
            n++;
            if(n<=k){
                maxpq.push(v);
            }else{
                if(v > maxpq.top()){
                    minpq.push(v);
                }else{
                    maxpq.push(v);
                    minpq.push(maxpq.top());
                    maxpq.pop();
                }
            }
        }else{
           ll ans=0;
            if(n<k){
                ans = -1;
            }else{
                n--;
                ans = maxpq.top();
                maxpq.pop();
                if(n>k){
                    maxpq.push(minpq.top());
                    minpq.pop();
                }
            }
            cout << ans << endl;
        }
    }

    return 0;
}

0