ABC 123 Editorial¶
Problem A: Five Antennas¶
Since the numbers are sorted, it is enough to look at the distance between the first and the last antenna. This will be the greatest possible distance. Thus if this distance is greater than k, then we output “:(“. Otherwise, we output “Yay!”. Sample code below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include<bits/stdc++.h>
using namespace std;
int main() {
int A[5], k;
for (int i=0; i<5; i++) cin >> A[i];
cin >> k;
if (A[4] - A[0] > k) {
cout << ":(";
return 0;
}
cout << "Yay!";
return 0;
}
|