結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2018-01-30 18:05:32 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 404 bytes |
コンパイル時間 | 876 ms |
コンパイル使用メモリ | 68,476 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-29 21:42:45 |
合計ジャッジ時間 | 2,018 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 WA * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:17:12: warning: ‘i’ may be used uninitialized [-Wmaybe-uninitialized] 17 | if(vc[i]<=L) | ^
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<cstdio> #include<cmath> #include<string> using namespace std; int main(){ long long L,N,x,i; vector<long long> vc; cin >> L >> N; while(N--){ cin >> x; vc.push_back(x); } sort(vc.begin(),vc.end()); if(vc[i]<=L) for(i=1;vc[i+1]<=L;i++){ L-=vc[i]; } cout << i; return 0; }