1. 程式人生 > >小蒟蒻初次CF滾粗+爆炸記 (Codeforces Round #466 Div.2)

小蒟蒻初次CF滾粗+爆炸記 (Codeforces Round #466 Div.2)

.cn reg tex cor using AI printf 刪掉 ref

比賽鏈接:http://codeforces.com/blog/entry/57981

小蒟蒻今天初次在ZCDHJ張大佬的帶領下,打了一場CF

(張大佬cnblogs鏈接:https://www.cnblogs.com/ZCDHJ)‘

英文完全看不懂,後面幾題直接放棄,各位dalao請見諒

T1:

題目鏈接:http://codeforces.com/contest/940/problem/A

題目大意:

給你一個n個數的集合,要求你刪掉若幹數,其中最大的差不應該超過d,求最小刪除量。

(小蒟蒻的英文水平也就只有這麽高了,各位dalao再次見諒)

張dalao認為這是一道紅題,然而小蒟蒻確認為這是一道橙題

題目難度不算大,直接上代碼了:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n,d;
int a[101];
int main()
{
    int ans=1e9;
    scanf("%d %d",&n,&d);
    for(register int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    if(d==0)
    {
        printf(
"0"); return 0; } sort(&a[1],&a[n+1]); for(register int i=1;i<=n;i++) { for(register int j=1;j<i;j++) if(a[i]-a[j]<=d) ans=min(ans,n+j-i-1); } printf("%d",min(n-1,ans)); return 0; }

就這麽多了,下面的題就不管了,吃飯去了(其實蒟蒻已經掛了)

小蒟蒻初次CF滾粗+爆炸記 (Codeforces Round #466 Div.2)