結果
| 問題 |
No.618 labo-index
|
| コンテスト | |
| ユーザー |
gzlcp
|
| 提出日時 | 2017-12-18 01:26:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,656 bytes |
| コンパイル時間 | 1,281 ms |
| コンパイル使用メモリ | 103,468 KB |
| 実行使用メモリ | 7,940 KB |
| 最終ジャッジ日時 | 2024-12-15 23:37:34 |
| 合計ジャッジ時間 | 6,831 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 5 WA * 30 |
ソースコード
#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;
}
}
gzlcp