結果

問題 No.449 ゆきこーだーの雨と雪 (4)
ユーザー Kmcode1Kmcode1
提出日時 2016-11-19 00:00:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 715 ms / 5,000 ms
コード長 2,146 bytes
コンパイル時間 2,083 ms
コンパイル使用メモリ 199,744 KB
実行使用メモリ 63,620 KB
最終ジャッジ日時 2023-10-23 15:00:20
合計ジャッジ時間 17,323 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 4 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 4 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 4 ms
4,348 KB
testcase_08 AC 4 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 279 ms
15,640 KB
testcase_13 AC 409 ms
26,008 KB
testcase_14 AC 369 ms
24,780 KB
testcase_15 AC 438 ms
26,528 KB
testcase_16 AC 396 ms
25,396 KB
testcase_17 AC 402 ms
25,212 KB
testcase_18 AC 288 ms
15,628 KB
testcase_19 AC 379 ms
24,560 KB
testcase_20 AC 365 ms
24,556 KB
testcase_21 AC 417 ms
25,936 KB
testcase_22 AC 414 ms
25,936 KB
testcase_23 AC 284 ms
15,896 KB
testcase_24 AC 388 ms
25,096 KB
testcase_25 AC 253 ms
14,460 KB
testcase_26 AC 205 ms
13,496 KB
testcase_27 AC 410 ms
25,924 KB
testcase_28 AC 405 ms
26,008 KB
testcase_29 AC 349 ms
24,536 KB
testcase_30 AC 420 ms
26,564 KB
testcase_31 AC 399 ms
25,964 KB
testcase_32 AC 352 ms
24,804 KB
testcase_33 AC 360 ms
25,360 KB
testcase_34 AC 248 ms
14,800 KB
testcase_35 AC 424 ms
26,592 KB
testcase_36 AC 254 ms
14,820 KB
testcase_37 AC 715 ms
63,620 KB
testcase_38 AC 460 ms
38,460 KB
testcase_39 AC 347 ms
38,460 KB
testcase_40 AC 349 ms
38,460 KB
testcase_41 AC 538 ms
41,816 KB
testcase_42 AC 550 ms
41,816 KB
testcase_43 AC 179 ms
18,352 KB
testcase_44 AC 197 ms
21,716 KB
testcase_45 AC 390 ms
63,620 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:72:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   72 |         scanf("%d", &t);
      |         ~~~~~^~~~~~~~~~
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);
      |                 ~~~~~^~~~~~~~~~~
main.cpp:77:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   77 |                 scanf("%s", buf);
      |                 ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define MAX 100007

int L[MAX];


int n;

int cnt[MAX];

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

char buf[500];

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

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

map<int, BIT> mp2;

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

vector<int> gain;

BIT bit;

map<int, int> MM;
map<int, int> CNT;
set<string> SS;

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;
		SS.insert(nam);
		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;
		}
		pat[nam] += gt(nn[0] - 'A');
		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++){
		string name = v[i].first;
		if (v[i].second[0] == '?'){
			int SUM = mp2[las_id[name]].sum(las_att[v[i].first]);
			SUM += bit.sum(MM.size()-1);
			SUM -= bit.sum(MM[las_id[name]]);
			if (SUM <= 0 || SUM > SS.size())return 1;
			printf("%d\n", SUM);
		}
		else{
			if (las_id.count(v[i].first)){
				mp2[las_id[name]].add(las_att[name], -1);
				bit.add(MM[las_id[name]], -1);
			}
			CNT[gain[i]]++;
			int cc = CNT[gain[i]];
			las_id[name] = gain[i];
			las_att[name] = cc-1;
			bit.add(MM[gain[i]], 1);
			mp2[gain[i]].add(cc - 1, 1);
		}
	}
	return 0;
}
0