結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2020-10-05 08:18:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 30 ms / 5,000 ms |
コード長 | 318 bytes |
コンパイル時間 | 597 ms |
コンパイル使用メモリ | 73,228 KB |
最終ジャッジ日時 | 2025-01-15 02:51:19 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:12:16: warning: ‘i’ is used uninitialized [-Wuninitialized] 12 | for(int i; i < n; i++) | ~~^~~ main.cpp:12:11: note: ‘i’ was declared here 12 | for(int i; i < n; i++) | ^
ソースコード
#include<iostream> #include<algorithm> using namespace std; int main(){ int k,n,to=0,q=0; cin >> k >> n; int a[n]; for(int i; i < n; i++) cin >> a[i]; sort(a,n+a); for(int i=0; i < n; i++){ to += a[i]; if(to <= k) q++; else break; } cout << q << endl; return 0; }