题解 P6367 【[COCI2006-2007#6] PRASE】
Analysis
简单模拟,用 std::map 存一下每个孩子取到的食物份数,设当前已经取了
Code
#include <map>
#include <string>
#include <iostream>
int n;
std::map<std::string, int> mp;
int main() {
std::cin >> n;
int ans = 0;
std::string tmp;
for (int i = 0; i < n; ++i) {
std::cin >> tmp;
int k = i - mp[tmp];
if (mp[tmp]++ > k) ++ans;
}
std::cout << ans << std::endl;
return 0;
}