結果

問題 No.5 数字のブロック
ユーザー focus
提出日時 2018-01-30 18:04:58
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 401 bytes
コンパイル時間 729 ms
コンパイル使用メモリ 68,452 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-29 21:41:20
合計ジャッジ時間 1,673 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21 WA * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:12: warning: ‘i’ may be used uninitialized [-Wmaybe-uninitialized]
   17 |     if(vc[i]<=L)
      |            ^

ソースコード

diff #

#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]<L;i++){
        L-=vc[i];
    }
    cout << i;
    return 0;
}
0