Accepted
foo.cc: In function 'int main()':
foo.cc:15:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d",&n);
 ~~~~~^~~~~~~~~
foo.cc:17:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d",&d[i]);
 ~~~~~^~~~~~~~~~~~
  正在同步测试数据,请稍后 [Hydro](https://hydro.ac)提供评测服务
代码
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int cmp(const int &a,const int &b)
{
if (a<b) return 1;
else return 0;
}
int main()
{
int n;
int d[6000000];
int a[6000000];
scanf("%d",&n);
for (int i=1;i<=n;i++)
scanf("%d",&d[i]);
sort(d+1,d+n+1,cmp);
int tot=0;
for (int i=n;i>=1;i--)
{
a[i]=0;
if (a[i+1]==0 && i!=n) goto loop;
a[i]=1;
for (int j=n;j>=i;j--)
if (d[j]-j+1>d[i]) {
a[i]=0;break;}
loop:tot=tot+a[i];
}
printf("%d",tot);
return 0;
}
      信息
- 递交者
 - 类型
 - 递交
 - 题目
 - P1082 自行车比赛
 - 题目数据
 - 下载
 - 语言
 - C++
 - 递交时间
 - 2021-08-21 14:15:27
 - 评测时间
 - 2021-08-21 14:15:27
 - 评测机
 
- 分数
 - 100
 - 总耗时
 - 5252ms
 - 峰值内存
 - 2.508 MiB