結果

問題 No.618 labo-index
ユーザー gzlcpgzlcp
提出日時 2017-12-18 01:26:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,656 bytes
コンパイル時間 1,121 ms
コンパイル使用メモリ 102,788 KB
実行使用メモリ 7,680 KB
最終ジャッジ日時 2023-08-22 05:18:47
合計ジャッジ時間 8,049 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 267 ms
7,680 KB
testcase_35 AC 270 ms
7,636 KB
testcase_36 AC 259 ms
6,228 KB
testcase_37 AC 274 ms
6,248 KB
testcase_38 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

ll N = 100010;
ll bit[100010];
void add(ll a, ll w) {
	for (ll x = a; x <= N; x += x & -x) bit[x] += w;
}
ll sum(ll a) {
	ll ret = 0;
	for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
 return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll q;
	cin>>q;
	vector<P> t(q);
	vector<ll> pos;	// 研究力の順位
	REP(i,q) cin>>t[i].first>>t[i].second;
	vector<P> buf;
	ll crt=0;
	REP(i,q) {
		if(t[i].first==1) {
			buf.pb(P(t[i].second,crt));
			crt++;
		}
	}
	pos.resize(crt);
	sort(ALL(buf));
	REP(i,(ll)buf.size()) {
		pos[buf[i].second]=i;
	}
	crt=0;
	ll ofs=0;
	REP(i,q) {
		if(t[i].first==1) {
			add(pos[crt]+1,1);
			crt++;
		}
		if(t[i].first==2) {
			add(pos[t[i].second-1]+1,-1);
		}
		if(t[i].first==3) {
			ofs+=t[i].second;
		}
		ll lb=0,ub=INF;
		while(ub-lb>1) {
			ll mid=(ub+lb)/2;
			ll hoge=mid-ofs;
			auto ite=lower_bound(ALL(buf),P(hoge,-1));
			ll foo=(ite-buf.begin());
			ll num=sum(q);
			if(foo>0) num-=sum(foo);
			if(num>=mid) lb=mid;
			else ub=mid;
		}
		cout<<lb<<endl;
	}
}
0