编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#45725 | #1020. jwp的采购之旅 | Compile Error | 0 | 0 ms | 0 K | C++ 11 / 343 B | 经济99-刘雨泽 | 2020-08-05 9:17:32 |
#include <iostream>
using namespace std;
int a[100001];
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
sort(a, a + n);
int j = 0;
for (int i = 0; i < n; i++) {
m -= a[i];
j++;
if (m <= 0)
break;
}
cout << j--;
return 0;
}
编译信息
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:9:5: error: 'sort' was not declared in this scope
sort(a,a+n);
^~~~
/sandbox/1/a.cpp:9:5: note: suggested alternative: 'qsort'
sort(a,a+n);
^~~~
qsort
/sandbox/1/a.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
~~~~~^~~~~~~~~~~~~~
/sandbox/1/a.cpp:8:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&a[i]);
~~~~~^~~~~~~~~~~~