Help In CHECHOC

lets say u take 3 3 8 10.
so, max u should get is: 4 X 2 + 5 X 8
i.e 48

This solution is giving WA. Am I missing any corner case?
FYI, I considered the corner case of 1x1 matrix.
https://www.codechef.com/viewsolution/36019255

sorry its giving correct for your solution, I was at mistake.

Yeah, I have missed the case for n=1 and m=1

Because it is only 1 element … since there are no adjacent to this… we need to print maximum X value …(our goal in problem was to find max. elements that can be filled)

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

1 Like

try the previous testcases everyone mentioned, like 3 3 8 10

https://www.codechef.com/viewsolution/35971993

Any test-cases for this one ?

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(); }
}