結果

問題 No.449 ゆきこーだーの雨と雪 (4)
ユーザー guestguest
提出日時 2016-11-20 00:00:26
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,175 bytes
コンパイル時間 2,341 ms
コンパイル使用メモリ 184,232 KB
実行使用メモリ 18,148 KB
最終ジャッジ日時 2024-09-22 10:27:14
合計ジャッジ時間 10,107 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other WA * 10 TLE * 1 -- * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>


#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(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;
 
int main(){
 
	int n, t;
	cin >>n;
	VI hs(n);
	unordered_map<string, VI> mp;
	map<pii, string> jn;
	vector<tuple<int,int,string>> jdt;
	VI nos(n);
	rep(i,n) cin >>hs[i];
	cin >> t;
	rep(i, t){
		string s;
		char a;
		cin >> s >> a;
		if(a != '?'){
			int osc=-1, ono=-1;
			if(!mp.count(s)) mp[s] = VI(n+2, 0);
			else { osc=mp[s][n+1]; ono=mp[s][n];}
			mp[s][n] = i+1;
			int mz= a-'A';
			mp[s][mz] = 50 * hs[mz] + (500 * hs[mz]) / (8 + 2* (++nos[mz]));
			mp[s][n+1]  += mp[s][mz];
			if(osc !=-1){
				auto it = upper_bound(all(jdt), make_tuple(-osc, ono, s));
				jdt.erase(it);
			}
			auto it = upper_bound(all(jdt), make_tuple(-mp[s][n+1], mp[s][n], ""));
			jdt.insert(it, make_tuple(-mp[s][n+1], mp[s][n],s));
		}else{
			int ans = upper_bound(all(jdt), make_tuple(-mp[s][n+1], mp[s][n], s)) - jdt.begin();
			cout << ans <<"\n";
		}
	}
	
	return 0;
}
 
0