记录详情

Accepted

foo.cc: In function 'int main()':
foo.cc:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~
foo.cc:7:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i <= n; i++) scanf("%d",&t[i]);
                              ~~~~~^~~~~~~~~~~~
正在同步测试数据,请稍后
# 状态 耗时 内存占用
#1 Accepted 2ms 384.0 KiB
#2 Accepted 2ms 384.0 KiB
#3 Accepted 2ms 384.0 KiB
#4 Accepted 1ms 384.0 KiB
#5 Accepted 2ms 384.0 KiB
#6 Accepted 2ms 384.0 KiB
#7 Accepted 1ms 384.0 KiB
#8 Accepted 2ms 384.0 KiB
#9 Accepted 1ms 384.0 KiB

代码

#include<bits/stdc++.h>
#define N 1001
using namespace std;
int n,m,now,t[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i = 1; i <= n; i++) scanf("%d",&t[i]);
	sort(t + 1, t + 1 + n);
	for(int i = 1; i <= n; i++){
		now += t[i] * (n - i + 1);
		if(now >= m){
			printf("Yes\n");
			exit(0);
		}
	}
	printf("No\n");
	return 0;
}

信息

递交者
类型
递交
题目
P1007 hitwh 2019 新生赛 H Songer and his army
语言
C++
递交时间
2020-12-21 14:36:45
评测时间
2020-12-21 14:36:45
评测机
分数
100
总耗时
19ms
峰值内存
384.0 KiB