Codeforces Round #565 (Div. 3)C. Lose it!
http://codeforces.com/contest/1176/problem/C
题意:在一串数组删除某些数字让他变成good的数组。good数组就是空数组或者{4,8,15,16,23,42} 可以按该顺序全部提取出来(n/6)组的数组。找出最小删除数。
比如:4,8,4,15,16,8,23,15,16,42,23,42
大致思路:把这六个数的位置分别入六个队列。提取出一组{4,8,15,16,23,42}即他们的位置从小到大能够找到一个序列。只要模拟提取的过程就可以了,模拟过程中不断修改位置。
代码如下:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define ll long long
#define pb push_back
using namespace std;
const int maxn=500009;
int a[maxn];
queue <int> Q[7];
int main()
{
int n,good=0;
cin>>n;
for (int i=1; i<=n; i++)
{
cin>>a[i];
if (a[i]==4)
Q[1].push(i);
else if (a[i]==8)
Q[2].push(i);
else if (a[i]==15)
Q[3].push(i);
else if (a[i]==16)
Q[4].push(i);
else if (a[i]==23)
Q[5].push(i);
else if (a[i]==42)
Q[6].push(i);
}
while(1)
{
int x=Q[1].front();
for (int i=2; i<=6; i++)
{
while(Q[i].front()<x&&!Q[i].empty())
{
Q[i].pop();
}
if (Q[i].empty())
break;
else if (i==6&&!Q[i].empty())
{
good+=6;
Q[6].pop();
}
else
{
x=Q[i].front();
Q[i].pop();
}
}
if (Q[1].empty()) break;
else Q[1].pop();
}
cout<<n-good<<endl;
}
今天打锐捷杯真的好自闭啊,wa两下就干脆再wa十下,最近这心态真的不太好,希望举办比赛能够谨慎一点,也希望自己能够调整好心态。