PROBLEM LINK:
PROBLEM LINK:
Contest Division 1
Contest Division 2
Contest Division 3
Contest Division 4
Setter: Daanish Mahajan
Tester: Harris Leung
Editorialist: Aman Dwivedi
DIFFICULTY:
Simple
PROBLEM:
The chef started watching a movie that runs for a total of XX minutes.
Chef has decided to watch the first Y minutes of the movie at twice the usual speed as he was warned by his friends that the movie gets interesting only after the first Y minutes.
How long will Chef spend watching the movie in total?
EXPLANATION:
Let’s watch Y minutes of the movie at twice the usual speed. Hence, it will require Y/2 minutes to watch the first Y minutes of the movie.
Now, the remaining part of the movie is of (X-Y) minutes and since we are watching this part with normal speed, hence it requires (X-Y) minutes in total.
Hence total time required to watch the entire movie is
This is our final answer, hence simply print this.
TIME COMPLEXITY:
O(1) per test case
SOLUTIONS:
Setter
#include<bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
#define LL long long
LL seed = chrono::steady_clock::now().time_since_epoch().count();
mt19937_64 rng(seed);
#define rand(l, r) uniform_int_distribution<LL>(l, r)(rng)
clock_t start = clock();
#define getchar getchar_unlocked
namespace IO {
long long readInt(char endd) {
long long ret = 0;
char c = getchar();
while (c != endd) {
ret = (ret * 10) + c - '0';
c = getchar();
}
return ret;
}
long long readInt(long long L, long long R, char endd) {
long long ret = readInt(endd);
assert(ret >= L && ret <= R);
return ret;
}
long long readIntSp(long long L, long long R) {
return readInt(L, R, ' ');
}
long long readIntLn(long long L, long long R) {
return readInt(L, R, '\n');
}
string readString(int l, int r) {
string ret = "";
char c = getchar();
while (c == '0' || c == '?' || c == '1') {
ret += c;
c = getchar();
}
assert((int)ret.size() >= l && (int)ret.size() <= r);
return ret;
}
}
using namespace IO;
const int TMAX = 1'00'000;
void solve() {
}
int main() {
int x = readIntSp(1, 1000);
int y = readIntLn(1, 1000);
cout << x - y / 2 << '\n';
assert(getchar() == EOF);
cerr << fixed << setprecision(10);
cerr << (clock() - start) / ((long double)CLOCKS_PER_SEC) << " secs\n";
return 0;
}
Tester
Editorialist
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int x,y;
cin>>x>>y;
cout<<(x-y)+y/2<<"\n";
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
t=1;
while(t--)
solve();
return 0;
}