結果

問題 No.2424 Josouzai
ユーザー stella1225stella1225
提出日時 2023-08-18 23:04:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 1,159 bytes
コンパイル時間 2,090 ms
コンパイル使用メモリ 208,404 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 05:35:19
合計ジャッジ時間 5,019 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 27 ms
5,376 KB
testcase_05 AC 93 ms
5,376 KB
testcase_06 AC 87 ms
5,376 KB
testcase_07 AC 86 ms
5,376 KB
testcase_08 AC 90 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 22 ms
5,376 KB
testcase_11 AC 72 ms
5,376 KB
testcase_12 AC 48 ms
5,376 KB
testcase_13 AC 28 ms
5,376 KB
testcase_14 AC 48 ms
5,376 KB
testcase_15 AC 8 ms
5,376 KB
testcase_16 AC 77 ms
5,376 KB
testcase_17 AC 23 ms
5,376 KB
testcase_18 AC 27 ms
5,376 KB
testcase_19 AC 46 ms
5,376 KB
testcase_20 AC 80 ms
5,376 KB
testcase_21 AC 63 ms
5,376 KB
testcase_22 AC 29 ms
5,376 KB
testcase_23 AC 35 ms
5,376 KB
testcase_24 AC 16 ms
5,376 KB
testcase_25 AC 83 ms
5,376 KB
testcase_26 AC 61 ms
5,376 KB
testcase_27 AC 87 ms
5,376 KB
testcase_28 AC 78 ms
5,376 KB
testcase_29 AC 68 ms
5,376 KB
testcase_30 AC 17 ms
5,376 KB
testcase_31 AC 40 ms
5,376 KB
testcase_32 AC 83 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i,a,n) for (int i = a; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
int mod = 998244353;
int INF = 1001001001;
using pll = pair<int,int>;

int Flag=0;

//デフォルトでNoがでる
void yn(int Flag){
  if(Flag==1){
    cout<<"Yes"<<endl;
  }
  else if(Flag==0){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Draw"<<endl;
  }
}

void cerrVec(vector<string> &V){
  int n=V.size();
  rep(i,0,n){
    for(auto x:V[i]){
      cerr<<x<<" ";
    }
    cerr<<endl;
  }
  cerr<<endl;
}

/*
  int H,W; cin>>H>>W;
  vector<vector<char>> C(H,vector<char> (W));
  rep(i,0,H) rep(j,0,W) cin>>C[i][j];
*/

int main(){
  int N,K; cin>>N>>K;
  vector<P> y(N);
  rep(i,0,N){
    cin>>y[i].first;
    y[i].second=i;
  }
  sort(all(y));
  ll sum=0;
  int idx=-1;
  int cnt=0;
  for(auto& x:y){
    auto [i,j]=x;
    if(sum+i>K){
      idx=cnt;
      break;
    }
    sum+=i;
    cnt++;
  }
  cout<<(idx==-1 ? N : idx)<<" ";
  cout<<max(ll(0), K-sum);
  cerr<<"sum "<<sum<<endl;
}
0