#include typedef long long ll; typedef unsigned long long ull; #define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++) #define REP(i,n) FOR(i,0,n) #define RANGE(vec) (vec).begin(),(vec).end() using namespace std; class TrendAndCountermeasures_PineDecorationSequence1 { public: void solve(void) { int T; cin>>T; // O(T*N^2) REP(t,T) { // // 5 5 5 5 4 4 4 3 2 9 1 // [5,4,3] [5,4,2] [5,4,9] ... 5,1 // // 同じものの数が多いものが残ってしまうと、作れる門松の数が減ってしまう。 // [5,4,3] [2,9,1] ... 5,5,5,4,4 // // よって数が多いものから貪欲に取っていけばよい。 // int N; cin>>N; map degree; REP(i,N) { int l; cin>>l; degree.emplace(l,0); ++degree[l]; } priority_queue pq; for (auto kv : degree) pq.push(kv.second); if (pq.size() < 3) { cout<<0< b > c の順なので c でチェックすれば十分 { cout<solve(); delete obj; return 0; } #endif