Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
A • Potato Sacks
#include <bits/stdc++.h> using namespace std; int main() { int P, K, capacidad, in, suma, cuenta; vector<int> saco; cin >> P; while(P--) { saco.clear(); suma = 0; cin >> K; cin >> capacidad; for(int i = 0; i < 10; i++) { cin >> in; saco.push_back(in); } sort(saco.begin(), saco.end()); cuenta = 0; while(cuenta<10) { suma += saco[cuenta]; //cout << "suma 1: " << suma << "\n"; if(suma == capacidad) { cout << K << " YES\n"; break; } if(suma > capacidad) break; cuenta++; } if(capacidad == suma) continue; if(suma < capacidad) { cout << K << " NO\n"; continue; } cuenta = 0; while(cuenta<10) { suma -= saco[cuenta]; //cout << "suma 2: " << suma << "\n"; if(suma == capacidad) { cout << K << " YES\n"; break; } if(suma < capacidad) break; cuenta++; } if(capacidad == suma) continue; cout << K << " NO\n"; } }
run
|
edit
|
history
|
help
0
Hi
project
Using copy_n
threadpool01
codeforces - 545D
CPP - Pointers - Ex.1
XD
2d array sum
Set of intervals.
26 და 28 მარტს დამუშავებული