Codeforces Round #565 (Div. 3) C. Lose it!

题目:https://codeforces.com/contest/1176/problem/C
思路:对于序列:\(4,8,15,16,23,42\),一个数可排仅当前一个数可用,可排将消耗其前一个数可用个数并增加自身可用个数

#include<bits/stdc++.h>

using namespace std;

#define DEBUG cout<<"DEBUG"<<endl

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int,int>pii;
typedef pair<ll,ll>pll;

typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pii> vpii;

int res;
int vis[10];
int mp[50];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //freopen("in.txt","r",stdin);
    mp[4]=0,mp[8]=1,mp[15]=2,mp[16]=3,mp[23]=4,mp[42]=5;
    int n;cin>>n;
    int res=0;
    for(int i=1;i<=n;i++)
    {
        int t;
        cin>>t;
        t=mp[t];
        if(!t) vis[t]++;
        else if(vis[t-1])
        {
            vis[t-1]--;
            vis[t]++;
        }
    }
    cout<<n-vis[5]*6;
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/c4Lnn/p/12113829.html