cf-div2-Codeforces Round #662 (Div. 2)

Codeforces Round #662 (Div. 2

A - Rainbow Dash, Fluttershy and Chess Coloring

#include
using namespace std;
typedef long long ll;
const int MAX=1e6+10;
const int mod=10;
 
void solve(){
    int n;
    cin>>n;
    cout<<(n/2+1)<<endl;
}
 
int main(){
    int t;
    cin>>t;
    while (t--){
        solve();
    }
    return 0;
}

B. Applejack and Storages

#include
using namespace std;
typedef long long ll;
const int MAX=1e5+10,mod=10;
int n,k,a[1<<17],b[1<<12];
char c;

int main(){
    cin>>n;
    while(n--) cin>>k,b[++a[k]]++;
    cin>>n;
    while(n--)
        cin>>c>>k,
        c=='+'?b[++a[k]]++:b[a[k]--]--,
        cout<<(b[8]>0||b[4]>1||(b[4]>0&&b[2]>2)||(b[2]>1&&b[6]>0)?"YES":"NO")<<endl;
    return 0;
}

C. Pinkie Pie Eats Patty-cakes

#include
using namespace std;
typedef long long ll;
const int MAX=1e5+10,mod=10;

int do_shit(){
    int n,i,shu,man=0,num=0,b[MAX]={0};
    for(cin>>n,i=1;i<=n;i++) cin>>shu,man=max(man,++b[shu]);
    for(i=1;i<=n;++i) if(b[i]==man) num++;
    return cout<<(n-man*num)/(man-1)-1+num<<endl,0;
}

int main(){
    int t;
    cin>>t;
    while (t--) do_shit();
    return 0;
}

你可能感兴趣的:(C++,acm,cf,acm竞赛,算法,c++)