Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 0 additions & 62 deletions 10 Days of Statistics.cpp

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Chef recently started working at ABC corporation. Let's number weekdays (Monday through Friday) by integers 1 through 5. For each valid i, the number of hours Chef spent working at the office on weekday i was Ai.

Unfortunately, due to the COVID-19 pandemic, Chef started working from home and his productivity decreased by a considerable amount. As per Chef's analysis, 1 hour of work done at the office is equivalent to P hours of work done at home.

Now, in order to complete his work properly, Chef has to spend more hours working from home, possibly at the cost of other things like sleep. However, he does not have to do the same work on each day as he would have in the office ? for each weekday, he can start the work for this day on an earlier day and/or complete it on a later day. The only requirement is that his work does not pile up indefinitely, i.e. he can complete his work for each week during the same week. One day has 24 hours.

If Chef is unable to complete his work for a week during those five weekdays, then he has to work during the weekend too. Chef wishes to know whether he has to work on weekends or if he can complete his work by working only on weekdays. Help him answer that question. (It is possible that Chef would be unable to finish his work even if he worked all the time, but he does not want to know about that.)

Input
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
The first and only line of each test case contains six space-separated integers A1, A2, A3, A4, A5 and P.
Output
For each test case, print a single line containing the string "Yes" if Chef has to work on weekends or "No" otherwise (without quotes).

Constraints
1=T=1,000
0=Ai=24 for each valid i
1=P=24
Subtasks
Subtask #1 (100 points): original constraints

Example Input
2
14 10 12 6 18 2
10 10 10 10 10 3
Example Output
No
Yes
Explanation
Example case 1: Here, P=2, so the number of hours Chef has to work from home to handle his workload for days 1 through 5 is [28,20,24,12,36]. If he works for full 24 hours on each of the five weekdays, he finishes all the work, so he does not have to work on weekends.

Example case 2: No matter what Chef does, he will have to work on weekends.
25 changes: 25 additions & 0 deletions Codechef- MayLunchtimeQ1_(Rated Contest)/Solution/Q1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <bits/stdc++.h>

using namespace std;

bool solve(){
int temp,p, sum=0;
for(int i=0; i<5; i++){
cin >> temp;
sum+=temp;
}
cin >> p;
return sum*p>120;
}

int main()
{
int t; cin >> t;
while(t--) {
if(solve())
cout << "Yes\n";
else
cout << "No\n";
}
return 0;
}
41 changes: 41 additions & 0 deletions Codechef_MayLunchtimeQ2_(Rated Contest)/Solution/Q2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vect_i;
long solve(){
int n; cin >> n;
vect_i a(n), b(n);

int sumA=0,sumB=0;

for(int i=0; i<n; i++){
cin >> a[i];
}

for(int i=0; i<n; i++){
cin >> b[i];
}

long weird_dist = (a[0]==b[0])?a[0]:0;
sumA=a[0]; sumB=b[0];
for(int i=1; i<n; i++){
if(a[i]==b[i]){
if(sumA==sumB)
weird_dist+=(long)a[i];
}
sumA+=a[i]; sumB+=b[i];
}

return weird_dist;

}

int main()
{
int t; cin >> t;
while(t--) {
cout << solve() << endl;
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Alice and Bob are walking on an infinite straight street. Initially, both are at the position X=0 and they start walking in the direction of increasing X. After N seconds, they stop. Let's denote Alice's speed and Bob's speed during the i-th of these seconds by Ai and Bi respectively.

Sometimes, Alice and Bob walk together, i.e. with the same speed side by side. Let's define the weird distance as the total distance they walk this way. Find this weird distance.

Input
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a single integer N.
The second line contains N space-separated integers A1,A2,�,AN.
The third line contains N space-separated integers B1,B2,�,BN.
Output
For each test case, print a single line containing one integer ? the total weird distance. It can be proved that this distance is an integer.

Constraints
1=T=20
1=N=105
1=Ai=105 for each valid i
1=Bi=105 for each valid i
the sum of N over all test cases does not exceed 106
Subtasks
Subtask #1 (30 points): 1=N=1,000
Subtask #2 (70 points): original constraints

Example Input
3
4
1 3 3 4
1 2 4 4
2
2 3
3 2
2
3 3
3 3
Example Output
5
0
6
Explanation
Example case 1:

Alice and Bob walk side by side during the first second, from X=0 to X=1.
Then, Alice starts walking faster than Bob, so they do not walk side by side during second 2. At the end of second 2, Alice is at X=4, while Bob is at X=3.
During the next second, they again do not walk side by side, but Bob walks faster, so they both end up at X=7.
During the last second, they both walk side by side and the distance they walk is 4.
Alice and Bob walk side by side during the 1-st and 4-th second and the total weird distance they travel is 1+4=5.
Example case 2:

First, Alice walks with speed 2 and Bob walks with speed 3, so they do not walk side by side. Alice ends up at X=2, while Bob ends up at X=3 at the end of the 1-st second.
Then, Alice walks with speed 3 and Bob walks with speed 2, so they do not walk side by side either.
Although Alice and Bob both end up at X=5 at the end of the 2-nd second, the weird distance is 0.
Example case 3: We can see that Alice and Bob always walk together, so the weird distance is 3+3=6.