楼主老哥。第二题可以观察规律,我没参加考试,菜鸡一枚,你看我这样对吗 const int N = 4e5 + 100; const int M = 4e5 + 100; int n,k; int a[N]; unordered_map<int,int> m; bool vis[N]; int main() { cin >> n >> k; for(int i = 1; i <= n; i++) { cin >> a[i]; } long long sum = 0; queue<int> dq; for(int i = 1; i <= n; i++) { m[a[i]]++; dq.push(i); if(vis[a[i]] == false && m[a[i]] >= k) { cout << a[i] << endl; sum += (n - i + 1); } } cout << sum << endl; }
点赞 1

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务