CodeChef: Practical coding for everyone can someone help me with this
I think it must be 45. If not, please explain.
This submission gets ac : CodeChef: Practical coding for everyone
But This doesnt get ac: CodeChef: Practical coding for everyone
The question clearly says sum cant be greater than y, Then how is the second one not ac
The minimum of x and y should have gotten ac, if(x>y) then answer is y or else x, But Second link gives WA
it should be like this for 3 3 8 10
8 2 8
2 8 2
8 2 8
total is 48
try the previous testcases everyone mentioned, like 3 3 8 10
I know
Just try the testcases from above, 3 3 8 10
gives WA for 1 1 4 1
U r getting WA because
at m=1,n=1,x=7,y=5
you have to print 7 & not 5.
this is the fault of problem setter. He must explain the question properly
They clearly said only adjacent elements sum should be Y. 1x1 matrix doesn’t have any element so the answer is X.
In the question it was clearly written that sum of adjacent cell should not exceed Y. But in case of 1x1 matrix there are nod adjacent cells. Edge case
Hi, Can you provide some test case where my solution fails!
Link: CodeChef: Practical coding for everyone
3 3 20 19
Still giving WA. Please help with the test case where it is failing.
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#define ll long long int
#define vll vector<long long int>
#define fo(n) for(ll j=0; j<n; j++)
#define pb push_back
#define sortv(v) sort(v.begin(), v.end())
using namespace std;
void solve() {
ll n, m, x, y;
cin >> n >> m >> x >> y;
if (n == 1 and m == 1) { cout << x << endl; }
else if (x <= y/2) { cout << n*m *x << endl; }
else {
if (m%2 == 0 or n%2 == 0) { cout << n*m*y / 2 << endl; }
else { cout << (m*n - 1) / 2 * y + min(x, y-1) << endl; }
}
}
int main() {
ll t;
cin >> t;
while (t--) { solve(); }
}
1 1 4 1
Sad mate.
Simple there is no adjacent cells so no matter what the answer is 100 ;
Sounds weird but this is the way !
Happy coding
It should be min(x, y) rather than min(x, y - 1)
Thanks man !! It worked. Got it.
Gotcha. One case cost me 100 points even after stress testing the solution to the max constraints. 