/ /

记录详情

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)提供评测服务
# 状态 耗时 内存占用
#1 Accepted 0ms 256.0 KiB
#2 Accepted 0ms 256.0 KiB
#3 Accepted 0ms 256.0 KiB
#4 Accepted 0ms 256.0 KiB
#5 Accepted 2ms 256.0 KiB
#6 Accepted 2ms 256.0 KiB
#7 Accepted 2ms 256.0 KiB
#8 Accepted 2ms 256.0 KiB
#9 Accepted 3ms 364.0 KiB
#10 Accepted 3ms 368.0 KiB
#11 Accepted 343ms 1.855 MiB
#12 Accepted 373ms 2.016 MiB
#13 Accepted 429ms 2.109 MiB
#14 Accepted 459ms 2.16 MiB
#15 Accepted 482ms 2.164 MiB
#16 Accepted 540ms 2.234 MiB
#17 Accepted 597ms 2.402 MiB
#18 Accepted 645ms 2.457 MiB
#19 Accepted 683ms 2.508 MiB
#20 Accepted 676ms 2.508 MiB

代码

#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