Submission #56258669
Source Code Expand
Copy
#include <bits/stdc++.h>#define endl "\n"# define int long longusing namespace std;const int MOD = 1e9+7;void solve() {int n,m; cin >> n >> m;vector<int> p(n);for(int i=0;i<n;++i) cin >> p[i];int maxv = *max_element(p.begin(),p.end());function<bool(int)> ok = [&](int mid){int cost = 0;for(int i=0;i<n;++i){cost+=min(mid,p[i]);}if(cost>m) return false;else return true;};int s=0,e=maxv+1;while(e-s>1){
#include <bits/stdc++.h> #define endl "\n" # define int long long using namespace std; const int MOD = 1e9+7; void solve() { int n,m; cin >> n >> m; vector<int> p(n); for(int i=0;i<n;++i) cin >> p[i]; int maxv = *max_element(p.begin(),p.end()); function<bool(int)> ok = [&](int mid){ int cost = 0; for(int i=0;i<n;++i){ cost+=min(mid,p[i]); } if(cost>m) return false; else return true; }; int s=0,e=maxv+1; while(e-s>1){ int m = s + (e-s)/2; if(ok(m)) s = m; else e = m-1; } if(ok(e)){ if(e==maxv+1) cout << "infinite" << endl; else cout << e << endl; }else cout << s << endl; } signed main() { int __ = 1; // cin >> __; while (__--) solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Transportation Expenses |
User | enough_cpi |
Language | C++ 20 (gcc 12.2) |
Score | 300 |
Code Size | 846 Byte |
Status | AC |
Exec Time | 57 ms |
Memory | 4768 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
All | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | AC | 1 ms | 3364 KB |
00_sample_02.txt | AC | 1 ms | 3480 KB |
00_sample_03.txt | AC | 1 ms | 3456 KB |
01_test_01.txt | AC | 53 ms | 4736 KB |
01_test_02.txt | AC | 52 ms | 4616 KB |
01_test_03.txt | AC | 53 ms | 4700 KB |
01_test_04.txt | AC | 53 ms | 4648 KB |
01_test_05.txt | AC | 52 ms | 4744 KB |
01_test_06.txt | AC | 52 ms | 4684 KB |
01_test_07.txt | AC | 53 ms | 4640 KB |
01_test_08.txt | AC | 53 ms | 4768 KB |
01_test_09.txt | AC | 11 ms | 3464 KB |
01_test_10.txt | AC | 17 ms | 3632 KB |
01_test_11.txt | AC | 53 ms | 4640 KB |
01_test_12.txt | AC | 52 ms | 4676 KB |
01_test_13.txt | AC | 52 ms | 4748 KB |
01_test_14.txt | AC | 52 ms | 4700 KB |
01_test_15.txt | AC | 53 ms | 4700 KB |
01_test_16.txt | AC | 53 ms | 4748 KB |
01_test_17.txt | AC | 52 ms | 4712 KB |
01_test_18.txt | AC | 57 ms | 4640 KB |
01_test_19.txt | AC | 57 ms | 4612 KB |
01_test_20.txt | AC | 1 ms | 3656 KB |
01_test_21.txt | AC | 53 ms | 4692 KB |
01_test_22.txt | AC | 53 ms | 4636 KB |
01_test_23.txt | AC | 52 ms | 4648 KB |
01_test_24.txt | AC | 53 ms | 4692 KB |
01_test_25.txt | AC | 53 ms | 4720 KB |