PROBLEM LINK:
Contest Division 1
Contest Division 2
Contest Division 3
Contest Division 4
Setter: S.Manuj Nanthan
Tester: Harris Leung
Editorialist: Trung Dang
DIFFICULTY:
355
PREREQUISITES:
None
PROBLEM:
Bob has X rupees and goes to a market. The cost of apples is Rs. A per kg and the cost of oranges is Rs. B per kg.
Determine whether he can buy at least 1 kg each of apples and oranges.
EXPLANATION:
We check if X is at least A + B or not.
TIME COMPLEXITY:
Time complexity is O(1).
SOLUTION:
Preparer's Solution
#include <bits/stdc++.h>
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
int apple_price , orange_price , bob_money;
cin>>bob_money>>apple_price>>orange_price;
if((apple_price + orange_price) <= bob_money)
cout<<"Yes";
else
cout<<"No";
return 0;
}
Tester's Solution
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
ll n;
void solve(int rr){
cin >> n;
int ans=0;
for(int i=1; i<=n ;i++){
int x;cin >> x;ans+=(x>=1000);
}
cout << ans << '\n';
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);
ll x,y,z;cin >> x >> y >> z;
if(x-y-z>=0) cout << "Yes\n";
else cout << "No\n";
}
Editorialist's Solution
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int x, a, b; cin >> x >> a >> b;
cout << (a + b <= x ? "Yes" : "No");
}