zoukankan      html  css  js  c++  java
  • 测试二发

    #include<iostream>
    #include<algorithm>
    #include<cstdio>
    using namespace std;
    long long sum;
    long long tot;
    long long k=1;
    long long a[100005];
    int n,m;
    int main()
    {
        cin>>n>>m;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            sum+=a[i];      //记录方块总数
        }
        sort(a,a+n);        //排序
        if(n==1)
        cout<<0;            //如果只有一排的话,直接输出0
        else {
        for(int i=0;i<n;i++)
        {
            if(i==n-1)      //最后一排特判一下,把之后的全部加上
            {
                if(a[i]<=k)
                tot++;
                else tot+=(a[i]-k+1);
                break;
            }
            if(a[i]>=k)
            {
                k++;
                tot++;
            }
            else tot++;
        }
        cout<<sum-tot;      //用总数减去要保留的就是所求结果要拿走的
        }
        return 0;
    }
    //k是我讲的现在考虑放在第几行
    
  • 相关阅读:
    ThinkPHP
    ThinkPHP
    静态化
    静态化
    静态化
    设计模式
    sublime
    静态化
    OPTIMIZE TABLE 小解
    information_schema系列八(事物,锁)
  • 原文地址:https://www.cnblogs.com/laioue/p/10048555.html
Copyright © 2011-2022 走看看