码题杯 云顶之奕 题型:模拟

40 阅读1分钟

码题集OJ-云顶之奕 (matiji.net)

#include <bits/stdc++.h>
using namespace std;
const int N = 510;
int cnt[N], len; //cnt记录每个元素出现了多少次,len记录备战席的长度

int main() {
	cin.tie(nullptr)->sync_with_stdio(0);
	for (int i = 1; i <= 8; i++) {
		int x;
		cin >> x;
		++cnt[x];
		++len;

		if (cnt[x] == 3) { //如果出现了三个一样的
			cnt[x] = 0;
			cnt[x * 10]++;
			len -= 2; //消去3个 新增1个 等于消去2个
		}
	}

	//补充队列
    int n ;
    cin >> n ; 
    for(int i = 1 ; i <= n ; ++ i)
    {
        int x ;
        cin >> x ;
        if ( cnt[x] == 2 )
        {
            cnt[x] = 0 ;
            cnt[x * 10] ++ ;
            len -- ;
            if ( cnt[x * 10] == 3 ) 
            {
                cnt[x * 100] ++ ;
                cnt[x * 10] = 0 ;
                len -= 2 ;
            }
        }
        else if ( len < 8 ) ++ cnt[x] , ++len ;
    }

  int m ;
    cin >> m ;
    for(int i = 500 ; i >= m ; -- i) 
	if ( cnt[i] )
	{
		cout << "YES YES YES\n";
		return 0 ;
	}
    cout << "NO NO NO\n" ;
	return 0;
}

image.png