結果

問題 No.449 ゆきこーだーの雨と雪 (4)
ユーザー kzyKTkzyKT
提出日時 2016-11-18 23:37:19
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,601 bytes
コンパイル時間 1,682 ms
コンパイル使用メモリ 181,080 KB
実行使用メモリ 29,632 KB
最終ジャッジ日時 2023-10-23 14:51:38
合計ジャッジ時間 9,019 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
12,944 KB
testcase_01 AC 4 ms
12,944 KB
testcase_02 AC 4 ms
12,944 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 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 178 ms
29,632 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 154 ms
22,364 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 129 ms
29,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
ll bit[500010];
class BIT{
public:
  ll n;
  BIT(){fill(bit,bit+500010,0);}
  void add(ll i,ll x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  ll sum(ll i){
    ll s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
};
bool cmp(PP a, PP b) {
  if(a.F==b.F) return a.S.F<b.S.F;
  return a.F>b.F;
}

P p[111111];
ll d[111111];
vector<PP> a;
vector<ll> c[111111];
ll b[111111];

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  ll n,m;
  cin >> n;
  int aa[n],bb[n];
  for(int i=0;i<n;i++) cin >> aa[i];
  cin >> m;
  memset(bb,0,sizeof(bb));
  map<string,int> mm;
  for(int i=0; i<m; i++) {
    string s;
    char c;
    ll x,y;
    cin >> s >> c;
    if(!mm.count(s)) {
      int k=mm.size();
      mm[s]=k;
    }
    x=mm[s];
    if(c=='?') y=-1;
    else {
      y=c-'A';
      bb[y]++;
      int z=50*aa[y]+(int)(50*aa[y]/(0.8+0.2*bb[y]));
      d[x]+=z;
      a.push_back(PP(d[x],P(i,x)));
    }
    p[i]=P(y,x);
  }
  for(int i=0; i<n; i++) a.push_back(PP(0,P(-1,i)));
  BIT t=BIT();
  t.n=a.size();
  a.push_back(PP(0,P(-1,-1)));
  ll k=a.size();
  sort(a.begin(),a.end(),cmp);
  for(int i=k-1; i>=0; i--) c[a[i].S.S].push_back(i+1);
  for(int i=0; i<n; i++) {
    t.add(c[i][b[i]],1);
    b[i]++;
  }
  for(int i=0; i<m; i++) {
    ll x=p[i].S;
    if(p[i].F>=0) {
      t.add(c[x][b[x]-1],-1);
      t.add(c[x][b[x]],1);
      b[x]++;
    } else cout << t.sum(c[x][b[x]-1]) << endl;
  }
  return 0;
}
0