Submission #3520663
Source Code Expand
#include <iostream> #include <algorithm> #include <vector> #include <iomanip> #include <map> #include <queue> #include <numeric> static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using namespace std; template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208; int main() { int n, k; cin >> n >> k; vector<int> v(n); for (auto &&i : v) scanf("%d", &i); sort(v.rbegin(), v.rend()); partial_sum(v.begin(), v.end(), v.begin()); for (int i = 0; i < n; ++i) { if(v[i] >= k){ cout << i+1 << "\n"; return 0; } } cout << -1 << "\n"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Credits |
User | firiexp |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 700 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:21:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] for (auto &&i : v) scanf("%d", &i); ^
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | corner_10, corner_11, corner_12, corner_13, max_14, random_00, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, sample_00, sample_01, sample_02 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
corner_10 | AC | 1 ms | 256 KB |
corner_11 | AC | 1 ms | 256 KB |
corner_12 | AC | 1 ms | 256 KB |
corner_13 | AC | 1 ms | 256 KB |
max_14 | AC | 1 ms | 256 KB |
random_00 | AC | 1 ms | 256 KB |
random_01 | AC | 1 ms | 256 KB |
random_02 | AC | 1 ms | 256 KB |
random_03 | AC | 1 ms | 256 KB |
random_04 | AC | 1 ms | 256 KB |
random_05 | AC | 1 ms | 256 KB |
random_06 | AC | 1 ms | 256 KB |
random_07 | AC | 1 ms | 256 KB |
random_08 | AC | 1 ms | 256 KB |
random_09 | AC | 1 ms | 256 KB |
sample_00 | AC | 1 ms | 256 KB |
sample_01 | AC | 1 ms | 256 KB |
sample_02 | AC | 1 ms | 256 KB |