結果

問題 No.449 ゆきこーだーの雨と雪 (4)
ユーザー imulanimulan
提出日時 2016-11-19 04:34:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,468 bytes
コンパイル時間 1,891 ms
コンパイル使用メモリ 189,144 KB
実行使用メモリ 20,516 KB
最終ジャッジ日時 2023-10-23 15:52:37
合計ジャッジ時間 19,731 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,624 KB
testcase_01 AC 2 ms
4,596 KB
testcase_02 AC 3 ms
4,596 KB
testcase_03 AC 3 ms
4,628 KB
testcase_04 AC 3 ms
4,628 KB
testcase_05 AC 3 ms
4,628 KB
testcase_06 AC 3 ms
4,628 KB
testcase_07 AC 3 ms
4,628 KB
testcase_08 AC 3 ms
4,628 KB
testcase_09 AC 3 ms
4,628 KB
testcase_10 AC 3 ms
4,628 KB
testcase_11 AC 3 ms
4,628 KB
testcase_12 AC 46 ms
5,012 KB
testcase_13 AC 320 ms
9,112 KB
testcase_14 AC 741 ms
9,116 KB
testcase_15 AC 176 ms
9,116 KB
testcase_16 AC 479 ms
9,112 KB
testcase_17 AC 422 ms
9,116 KB
testcase_18 AC 44 ms
5,012 KB
testcase_19 AC 656 ms
9,112 KB
testcase_20 AC 925 ms
9,116 KB
testcase_21 AC 342 ms
9,116 KB
testcase_22 AC 316 ms
9,116 KB
testcase_23 AC 44 ms
5,012 KB
testcase_24 AC 510 ms
9,116 KB
testcase_25 AC 46 ms
5,012 KB
testcase_26 AC 49 ms
5,012 KB
testcase_27 AC 372 ms
9,116 KB
testcase_28 AC 348 ms
9,116 KB
testcase_29 AC 726 ms
9,116 KB
testcase_30 AC 192 ms
9,116 KB
testcase_31 AC 292 ms
9,116 KB
testcase_32 AC 1,223 ms
9,116 KB
testcase_33 AC 850 ms
9,116 KB
testcase_34 AC 45 ms
5,012 KB
testcase_35 AC 231 ms
9,116 KB
testcase_36 AC 45 ms
5,012 KB
testcase_37 AC 95 ms
20,516 KB
testcase_38 TLE -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

struct SumSegTree{
    long n; vector<ll> dat;
    //初期化
    SumSegTree(long _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<ll>(2*n-1,0);
    }
    //k番目(0-indexed)の値を+a
    void add(long k, ll a){
        k+=n-1;
        dat[k]+=a;
        //更新
        while(k>0){
            k=(k-1)/2;
            dat[k]=dat[2*k+1]+dat[2*k+2];
        }
    }
    //内部的に投げられるクエリ
    ll _query(long a, long b, long k, long l, long r){
        if(r<=a || b<=l) return LLONG_MIN;

        if(a<=l && r<=b) return dat[k];
        else{
            ll vl=_query(a,b,2*k+1,l,(l+r)/2);
            ll vr=_query(a,b,2*k+2,(l+r)/2,r);
            return vl+vr;
        }
    }
    //[a,b)の最大値を求める
    ll query(long a, long b){
        return _query(a,b,0,0,n);
    }
};

inline int score(int l,int ac)
{
    return 50*l + (int)(floor(0.000001+50*l/(0.8+0.2*ac)));
}

const int N=16000;
set<int> s[N];
SumSegTree st(N);

int main()
{
    cin.tie(0);ios::sync_with_stdio(false);

    int n;
    cin >>n;
    vector<int> L(n);
    rep(i,n) cin >>L[i];

    vector<int> ac(n,0),sum,last;
    int participant=0;
    unordered_map<string,int> name_to_id;

    int T;
    cin >>T;
    rep(i,T)
    {
        string name;
        char p;
        cin >>name >>p;
        if(p=='?')
        {
            int id = name_to_id[name];

            int up = st.query(sum[id]+1,N);
            int same = distance(s[sum[id]].begin(), s[sum[id]].find(last[id]));
            printf("%d\n", up+same+1);
        }
        else
        {
            if(name_to_id.find(name)==name_to_id.end())
            {
                name_to_id[name] = participant++;
                sum.pb(0);
                last.pb(0);
            }

            int id = name_to_id[name];
            int problem = p-'A';

            ++ac[problem];

            if(sum[id]!=0)
            {
                s[sum[id]].erase(last[id]);
                st.add(sum[id],-1);
            }
            sum[id] += score(L[problem],ac[problem]);
            last[id]=i;
            s[sum[id]].insert(i);
            st.add(sum[id],1);
        }
    }
    return 0;
}
0