結果

問題 No.1046 Fruits Rush
ユーザー LV3zJigVW57oPGy
提出日時 2022-11-12 17:05:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 1,596 ms
コンパイル使用メモリ 163,032 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-14 07:07:58
合計ジャッジ時間 2,050 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 
using namespace std;
#include <stdio.h>
#include <iomanip>
#include <iostream>
#include <string>
#include <algorithm>

int main(){
  int a, b;
  int count=0;
  cin >> a >> b;
  vector<int> vec(a);
  for(int i=0;i<a;i++){
    cin >> vec.at(i);
  }
  sort(vec.rbegin(),vec.rend());
  for(int i=0;i<b;i++){
    int c = count;
    count += vec.at(i);
   if(i>0&&c>count){
     count = c;
     break;
   }
  }
  cout << count;
    
}
0