Search for a command to run...
Progressive hints first, then the full explanation and implementation when you're ready to cash out.
Review status
AI-generated and still unreviewed. Double-check the details before internalizing them.
Hints
Open only as much as you need to keep the solve alive.
What is the point value of a single subtask? If you want to score exactly , what must be true about at least one of the ?
If no problem has , every subtask is worth at least points. Can a contestant ever reach a total of ? What does that immediately tell you about the answer?
Suppose some problem has , so it alone can produce every integer from to . Look at the remaining problems: each of them contributes a score in the range . Prove by induction that the sumset of any collection of such problems never contains a gap larger than .
Let be the set of scores achievable by the problems other than the one with . You now know that consecutive elements of differ by at most . The total achievable set is . Why do these overlapping intervals guarantee coverage of every integer from to ?
The answer is Yes if and only if some . If none equal , the smallest positive step is , so a total of is impossible. If some equal , that problem yields the full interval , and the others patch the rest because their combined sumset has gaps of at most , exactly filling .
The -th problem offers scores Because every divides , the step size is a positive integer.
If we need every integer total from to , we certainly need . A contestantβs total is a sum of non-negative integer multiples of the step sizes . The smallest positive value any single problem can contribute is . Therefore, score is reachable iff some problem has step , i.e. If no equals , every positive total is at least , so the answer is immediately No.
Assume problem satisfies . It alone yields every integer in . Let be the set of scores achievable by the remaining problems. For each remaining problem , its score set is a subset of containing . We claim the sorted elements of have gaps of at most :
Proof by induction. For one problem the claim is trivial because . Assume it holds for a sumset , and let where and . Take any that is not the maximum. Write .
Thus a successor always exists within , proving the claim.
The total achievable set is Because consecutive elements of differ by at most , these closed intervals overlap (or at least touch). Since and , their union is exactly the continuous integer interval Hence the answer is Yes.
We only need to check whether the input contains the value .
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void setIO() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
int main() {
setIO();
int T;
if (!(cin >> T)) return 0;
while (T--) {
int n;
cin >> n;
bool has100 = false;
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
if (x == 100) has100 = true;
}
cout << (has100 ? "Yes" : "No") << '\n';
}
return 0;
}#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void setIO() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
int main() {
setIO();
int T;
if (!(cin >> T)) return 0;
while (T--) {
int n;
cin >> n;
bool has100 = false;
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
if (x == 100) has100 = true;
}
cout << (has100 ? "Yes" : "No") << '\n';
}
return 0;
}