結果
| 問題 |
No.449 ゆきこーだーの雨と雪 (4)
|
| ユーザー |
|
| 提出日時 | 2016-11-19 00:16:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 2,625 bytes |
| コンパイル時間 | 2,724 ms |
| コンパイル使用メモリ | 205,804 KB |
| 実行使用メモリ | 814,680 KB |
| 最終ジャッジ日時 | 2024-09-22 10:16:11 |
| 合計ジャッジ時間 | 6,026 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | MLE * 1 -- * 2 |
| other | -- * 43 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
template<class Val>
struct BinaryIndexedTree{
int n;
vector<Val> t;
BinaryIndexedTree(){}
BinaryIndexedTree(int _n):n(_n+1), t(_n+1){}
void add(int k, Val val){
k++;
while(k < n){
t[k] += val;
k += (k&-k);
}
}
Val sum(int k){
Val r = 0;
while(k > 0){
r += t[k];
k -= (k&-k);
}
return r;
}
Val sum(int l, int r){
return sum(r) - sum(l);
}
};
typedef BinaryIndexedTree<int> BIT;
int f(int x, int y) {
return 50 * x + 500 * x / (8 + 2 * y);
}
int MA = 600000001;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int N;
while(cin >> N) {
BIT sum(MA);
vi L(N);
vi cnt(N);
map<string, int> pt;
rep(i, N) {
cin >> L[i];
}
// ポイント=>pair<名前、時刻>
map<int, set<pair<string, int>>> ptn;
int T;
cin >> T;
rep(i, T) {
string name;
char c;
cin >> name >> c;
if(c == '?') {
int x = pt[name];
int rank = sum.sum(x + 1, MA);
vector<pair<int, string>> v;
each(p, ptn[pt[name]]) {
v.emplace_back(p.second, p.first);
}
sort(all(v));
rep(j, sz(v)) {
++rank;
if(v[j].second == name) {
break;
}
}
cout << rank << endl;
} else {
int p = c - 'A';
// f(L[p], ++cnt[p]);
if(pt.count(name)) {
sum.add(pt[name], -1);
auto it = ptn[pt[name]].lower_bound(mp(name, 0));
ptn[pt[name]].erase(it);
}
pt[name] += f(L[p], ++cnt[p]);
sum.add(pt[name], 1);
ptn[pt[name]].insert(mp(name, i));
}
}
}
}