제출 #3952

#제출 시각아이디문제언어결과실행 시간메모리
3952zzapcoderKing of penalty (kriii1_K)C++98
0 / 1
0 ms1672 KiB
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { int n,p; cin>>p>>n; vector<int> vll(n,0); for(int i=0;i<n;++i) cin>>vll[i]; sort(vll.begin(), vll.end()); int leftTime = p-1; int ans = 0, idx = 0; while( leftTime >= 0 ){ if(idx < vll.size() && vll[idx] <= leftTime){ ans += leftTime; leftTime -= vll[idx]; idx++; } else break; } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...