unordered_multiset求助

CF1146A Love "A"

ACCode: ``` #include<cstdio> #include<cctype> int n,a;char c; const int& min(const int& a,const int& b) { return a<b?a:b; } int main() { while(c=getchar(),islower(c)) { n++,a+=c=='a'; } printf("%d",min(a*2-1,n)); return 0; } ```
by Miller2019 @ 2020-07-27 17:32:15


帮帮这个刚进oi的萌新吧
by Miller2019 @ 2020-07-27 17:37:17


```cpp #include<cstdio> #include<cctype> #include<iostream> #include<unordered_set> std::unordered_multiset<char>str; using namespace std; char c; int main() { while(scanf("%c",&c),islower(c)) { str.insert(c); } cout << std::min(str.size(),str.count('a')*2-1); return 0; } ```
by 数学课代表OvO @ 2020-07-27 17:42:47


0*2-1ull溢出?
by dead_X @ 2020-07-27 17:42:49


@[Miller2019](/user/256340) 不会用printf的时候用cout吧
by 数学课代表OvO @ 2020-07-27 17:43:24


@[dead_X](/user/111055) 取了min,不可能是因为这个
by 数学课代表OvO @ 2020-07-27 17:47:22


@[dead_X](/user/111055) 而且 count 返回值是 difference_type 是个有符号整数吧
by 数学课代表OvO @ 2020-07-27 17:49:36


@[数学课代表OvO](/user/326595) 那为什么ide会t
by Miller2019 @ 2020-07-27 17:51:15


@[Miller2019](/user/256340) 我猜你没在输入结束处打换行符
by 数学课代表OvO @ 2020-07-27 17:52:21


@[数学课代表OvO](/user/326595) 啊这,我一直以为scanf返回EOF时也会给字符赋值为EOF。。。
by Miller2019 @ 2020-07-27 17:55:42


| 下一页