Accepted
/in/foo.cc: In function 'int read()': /in/foo.cc:5:30: warning: suggest parentheses around '&&' within '||' [-Wparentheses] while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar()); ~~~~~~~^~~~~~~
代码
#include <bits/stdc++.h>
using namespace std;
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
return f?x:-x;
}
int a[100020];
int main() {
int n = read(), m = read();
for (int i = 1; i <= n; ++ i) {
a[i] = read();
}
sort(a + 1, a + n + 1);
long long d = 0;
for (int i = 1; i <= n; ++ i) {
d += (long long) a[i] * (n - i + 1);
}
puts(d >= m ? "Yes" : "No");
}
信息
- 递交者
- 类型
- 递交
- 题目
- P1007 hitwh 2019 新生赛 H Songer and his army
- 语言
- C++
- 递交时间
- 2020-12-16 23:39:25
- 评测时间
- 2020-12-16 23:39:25
- 评测机
- 分数
- 100
- 总耗时
- 12ms
- 峰值内存
- 232.0 KiB