結果
問題 | No.449 ゆきこーだーの雨と雪 (4) |
ユーザー | Kmcode1 |
提出日時 | 2016-11-18 23:15:47 |
言語 | C++11 (gcc 11.4.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,985 bytes |
コンパイル時間 | 1,934 ms |
コンパイル使用メモリ | 195,512 KB |
実行使用メモリ | 54,572 KB |
最終ジャッジ日時 | 2024-09-22 09:35:13 |
合計ジャッジ時間 | 9,604 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | AC | 551 ms
53,580 KB |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | AC | 421 ms
36,500 KB |
testcase_42 | RE | - |
testcase_43 | RE | - |
testcase_44 | RE | - |
testcase_45 | AC | 319 ms
54,572 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:66:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 66 | scanf("%d", &t); | ~~~~~^~~~~~~~~~ main.cpp:68:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 68 | scanf("%s", buf); | ~~~~~^~~~~~~~~~~ main.cpp:70:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 70 | scanf("%s", buf); | ~~~~~^~~~~~~~~~~
ソースコード
#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 = 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<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; 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; } 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 >= n + 1)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; }