結果

問題 No.449 ゆきこーだーの雨と雪 (4)
ユーザー guestguest
提出日時 2016-11-20 09:40:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 221 ms / 5,000 ms
コード長 1,594 bytes
コンパイル時間 1,994 ms
コンパイル使用メモリ 186,976 KB
実行使用メモリ 27,016 KB
最終ジャッジ日時 2023-10-23 15:57:14
合計ジャッジ時間 9,449 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 5 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 124 ms
9,152 KB
testcase_13 AC 170 ms
14,188 KB
testcase_14 AC 140 ms
12,668 KB
testcase_15 AC 182 ms
15,080 KB
testcase_16 AC 157 ms
13,284 KB
testcase_17 AC 154 ms
13,288 KB
testcase_18 AC 127 ms
9,152 KB
testcase_19 AC 138 ms
12,664 KB
testcase_20 AC 134 ms
12,656 KB
testcase_21 AC 166 ms
14,184 KB
testcase_22 AC 169 ms
14,184 KB
testcase_23 AC 126 ms
9,152 KB
testcase_24 AC 152 ms
13,288 KB
testcase_25 AC 106 ms
7,832 KB
testcase_26 AC 85 ms
6,776 KB
testcase_27 AC 167 ms
14,180 KB
testcase_28 AC 169 ms
14,192 KB
testcase_29 AC 137 ms
12,652 KB
testcase_30 AC 178 ms
15,076 KB
testcase_31 AC 171 ms
14,192 KB
testcase_32 AC 134 ms
12,664 KB
testcase_33 AC 148 ms
13,300 KB
testcase_34 AC 108 ms
7,832 KB
testcase_35 AC 179 ms
15,092 KB
testcase_36 AC 107 ms
7,832 KB
testcase_37 AC 221 ms
27,016 KB
testcase_38 AC 147 ms
15,976 KB
testcase_39 AC 136 ms
15,976 KB
testcase_40 AC 134 ms
15,976 KB
testcase_41 AC 178 ms
19,144 KB
testcase_42 AC 180 ms
19,144 KB
testcase_43 AC 109 ms
8,360 KB
testcase_44 AC 140 ms
11,000 KB
testcase_45 AC 215 ms
27,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>


#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define dnmin(a,b) (a)=min((a),(b))

using namespace std;
typedef vector<int> VI;
typedef pair<int, int> pii;

struct Bitree {
	typedef int btT;
	vector<btT> bv;
	Bitree(int n) : bv(n + 3) {}
	btT sum(int i) {
		btT res=0; for(i++; i>0; i -= i & -i) res += bv[i]; return res;
	}
	btT sum(int a, int b) {return sum(b) - (a? sum(a-1): 0);}
	void add(int i, btT x){for(i++; i<(int)bv.size(); i += i & -i) bv[i] += x; }
	void updt(int i, btT x){ add(i, x - sum(i,i));} //replace, update
};


int main(){
 
	int n, t, mno=0;
	cin >>n;
	VI hs(n);
	unordered_map<string, VI> mp;
	map<int64_t, int> zat;
	rep(i,n) cin >>hs[i];
	cin >> t;
	VI nos(n),  nm(t);
	vector<int64_t> vl(t);
	rep(i, t){
		string s; char a;
		cin >> s >> a;
		if(!mp.count(s)) mp[s] = VI{ 0,0, ++mno};
		if(a != '?'){
			mp[s][1] = i+1;
			int mz= a-'A';
			mp[s][0] += 50 * hs[mz] + (500 * hs[mz]) / (8 + 2* (++nos[mz]));
			vl[i]  = 1000000LL * mp[s][0] + 500000LL - mp[s][1];
			zat[vl[i]] = 0;
		}
		nm[i] = mp[s][2] * 10 + (a=='?');
	}
	int ct=1;
	for(auto& x: zat) x.second = ct++;
	
	VI cpt(sz(mp)+4);
	Bitree bta(t+10);

	rep(i,t){
		if(nm[i]%10 !=1 ){
			if(cpt[nm[i]/10] !=0 ) bta.add(cpt[nm[i]/10], -1);
			bta.add(zat[vl[i]], 1);
			cpt[nm[i]/10] = zat[vl[i]];
		}else{
			int ans = bta.sum(cpt[nm[i]/10] + 1, t + 5);
			cout << ans + 1 << "\n";
		}
	}
	//for(auto x: cpt) printf("%d:%d  ",x.first, x.second);
	//rep(i,t+1) printf("%d:%d  ",i,bta.sum(i,i));
	//return 0;
}
 
0