結果

問題 No.449 ゆきこーだーの雨と雪 (4)
ユーザー Kmcode1Kmcode1
提出日時 2016-11-18 23:04:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,210 bytes
コンパイル時間 3,354 ms
コンパイル使用メモリ 206,544 KB
実行使用メモリ 65,748 KB
最終ジャッジ日時 2023-10-22 08:33:39
合計ジャッジ時間 21,740 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 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 AC 4 ms
4,348 KB
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 867 ms
65,748 KB
testcase_38 AC 532 ms
39,272 KB
testcase_39 AC 425 ms
39,272 KB
testcase_40 AC 437 ms
39,272 KB
testcase_41 AC 728 ms
48,552 KB
testcase_42 AC 738 ms
48,552 KB
testcase_43 AC 251 ms
24,564 KB
testcase_44 AC 360 ms
32,640 KB
testcase_45 AC 490 ms
65,748 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:70:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   70 |         scanf("%d", &t);
      |         ~~~~~^~~~~~~~~~
main.cpp:72:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   72 |                 scanf("%s", buf);
      |                 ~~~~~^~~~~~~~~~~
main.cpp:74:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   74 |                 scanf("%s", buf);
      |                 ~~~~~^~~~~~~~~~~

ソースコード

diff #

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

int L[MAX];


int n;

int cnt[MAX];

int gt(int id){
	cnt[id]++;
	int val = 50 * L[id];
	val += floor(50.0 * (double)L[id] / (0.8 + 0.2*(double)(cnt[id])));
	return val;
}
vector<pair<string, string> > v;

char buf[500];

map<int, vector<string> > mp;
map<string, int> pat;

struct BIT{
	vector<long double> bit;
	void resize(int N){
		bit.assign(N+5, 0);
	}
	void add(int i, long double j){
		i++;
		while (i < bit.size()){
			bit[i] += j;
			i += i&-i;
		}
	}
	long double sum(int i){
		long double r = 0;
		i++;
		while (i){
			r += bit[i];
			i -= i&-i;
		}
		return r;
	}
};

map<int, int> cnt2;
map<int, BIT> mp2;

map<string, int> las_id;
map<string, int> las_att;

vector<int> gain;
vector<int> ich;

BIT bit;

map<int, int> MM;
map<int, int> CNT;

map<int, set<string> > solved;

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> L[i];
	}
	int t;
	scanf("%d", &t);
	for (int i = 0; i < t; i++){
		scanf("%s", buf);
		string nam = buf;
		scanf("%s", buf);
		string nn = buf;
		v.push_back(make_pair(nam, nn));
		if (pat.count(nam)){

		}
		else{
			pat[nam] = 0;
		}
		if (nn[0] == '?'){
			gain.push_back(0);
			continue;
		}
		else{
			
		}
		pat[nam] += gt(nn[0] - 'A');
		if (solved[pat[nam]].count(nam)){
			v.pop_back();
			continue;
		}
		solved[pat[nam]].insert(nam);
		mp[pat[nam]].push_back(nam);
		gain.push_back(pat[nam]);
	}
	t = v.size();
	int ii = 0;
	for (auto it = mp.begin(); it != mp.end(); it++){
		mp2[(*it).first].resize((*it).second.size() + 1);
		MM[(*it).first] = ii;
		ii++;
	}
	bit.resize(MM.size());
	for (int i = 0; i < t; i++){
		if (v[i].second[0] == '?'){
			int SUM = mp2[las_id[v[i].first]].sum(las_att[v[i].first]);
			SUM += bit.sum(MM.size()-1);
			SUM -= bit.sum(MM[las_id[v[i].first]]);
			printf("%d\n", SUM);
		}
		else{
			if (las_id.count(v[i].first)){
				mp2[las_id[v[i].first]].add(las_att[v[i].first], -1);
				bit.add(MM[las_id[v[i].first]], -1);
			}
			gt(v[i].second[0]-'A');
			CNT[gain[i]]++;
			int cc = CNT[gain[i]];
			las_id[v[i].first] = gain[i];
			las_att[v[i].first] = cc-1;
			bit.add(MM[las_id[v[i].first]], 1);
			mp2[gain[i]].add(cc - 1, 1);
		}
	}
	return 0;
}
0