标签:target play contest one test c++ int codeforce printf
#include <bits/stdc++.h> using namespace std; int N, M; int main() { scanf("%d%d", &N, &M); int ans; if(N == M) ans = 0; else if(M == 0 || M == 1 || M == N - 1) ans = 1; else { if(M <= N / 2) ans = M; else ans = N - M; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int N; int a[maxn]; map<int, int> mp; map<int, int> cnt; int main() { scanf("%d", &N); int ans = 0, maxx = -1, vis = 0; int flag = -1; for(int i = 1; i <= N; i ++) { scanf("%d", &a[i]); if(mp[a[i]] == 0) vis ++; cnt[mp[a[i]]] --; mp[a[i]] ++; cnt[mp[a[i]]] ++; maxx = max(maxx, mp[a[i]]); if(vis - 1 == cnt[maxx - 1] && cnt[maxx] == 1) ans = i, flag = 1; if(vis == cnt[1]) ans = i + 1, flag = 2; if(cnt[1] == 1 && cnt[maxx] == vis - 1) ans = i, flag = 3; } ans = min(N, ans); printf("%d\n", ans); return 0; }
读题读错白白抑郁一天 今天可能写了史上最 lao 的 bug 我为什么还要把它给 FH 看???
标签:target play contest one test c++ int codeforce printf
原文地址:https://www.cnblogs.com/zlrrrr/p/10908880.html