提出 #72540387


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#include <climits>
#define no cout << "No" << endl;
#define yes cout << "Yes" <<endl;
using ll = long long ;
using P=pair<int,int>;
//N×M vector<vector<int>> A(N,vector<int>(M)); A[i][j] A.push_back(data);
//sort (b.begin(),b.end()); if(b.size() >=2);
//int keta = to_string(b).length(); pow(10,keta);
//set<int> a; a.insert(da); a.count(da) for(auto v: a)
//using P=pair<int,int>;vector<P> c;c.emplace_back(da,i) //index保持
//auto dfs =[&](auto f, int i, int j) -> void {};
//b ha kihon zentansaku
//shoujin houhou komentodake nokosite mosha
//set<pair<int,int>> st;st.insert({r,c});st.count({x,y})

int main() {
    int n,k;
    ll x;
    cin >> n >> k >> x;
    vector<int> A(n);
    rep(i,n)cin >> A[i];

    sort(A.rbegin(),A.rend());
    rep(i,n){
        if(i<n-k){
            A[i] =0;
        }
    }
    vector<ll> s(n+1);
    rep(i,n) s[i+1] = s[i] + A[i];
    
    int it = lower_bound(s.begin(), s.end(), x)-s.begin();
    if(it == s.size()){
        cout << "-1" << endl;
        return 0;
    }
    cout << it  << endl;


}

提出情報

提出日時
問題 C - Sake or Water
ユーザ BvBDnl26
言語 C++23 (GCC 15.2.0)
得点 300
コード長 1168 Byte
結果 AC
実行時間 95 ms
メモリ 6932 KiB

コンパイルエラー

./Main.cpp: In function 'int main()':
./Main.cpp:36:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     if(it == s.size()){
      |        ~~~^~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 33
セット名 テストケース
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 1 ms 3392 KiB
example_01.txt AC 1 ms 3608 KiB
example_02.txt AC 1 ms 3544 KiB
hand_00.txt AC 83 ms 6932 KiB
hand_01.txt AC 83 ms 6868 KiB
hand_02.txt AC 73 ms 6728 KiB
hand_03.txt AC 73 ms 6756 KiB
hand_04.txt AC 73 ms 6844 KiB
hand_05.txt AC 73 ms 6832 KiB
hand_06.txt AC 73 ms 6800 KiB
hand_07.txt AC 1 ms 3484 KiB
hand_08.txt AC 1 ms 3412 KiB
hand_09.txt AC 1 ms 3604 KiB
hand_10.txt AC 1 ms 3440 KiB
hand_11.txt AC 84 ms 6844 KiB
random_00.txt AC 94 ms 6756 KiB
random_01.txt AC 94 ms 6832 KiB
random_02.txt AC 95 ms 6932 KiB
random_03.txt AC 95 ms 6832 KiB
random_04.txt AC 94 ms 6824 KiB
random_05.txt AC 95 ms 6728 KiB
random_06.txt AC 93 ms 6852 KiB
random_07.txt AC 94 ms 6876 KiB
random_08.txt AC 94 ms 6756 KiB
random_09.txt AC 95 ms 6876 KiB
random_10.txt AC 94 ms 6728 KiB
random_11.txt AC 95 ms 6856 KiB
random_12.txt AC 94 ms 6868 KiB
random_13.txt AC 94 ms 6768 KiB
random_14.txt AC 94 ms 6832 KiB
random_15.txt AC 94 ms 6756 KiB
random_16.txt AC 94 ms 6844 KiB
random_17.txt AC 94 ms 6852 KiB