My logic for CHECHOC:
Creating 2 rows one with minimum sum(i.e 1 4 1 4 1) and another with maximum sum possible(4 1 4 1 4)
and then calculating sum with both assuming row1 as 1st and row2 as first ans then returning maximum of the two sum.
This approach gives a WA. Can someone please provide a countercase?
*#include <bits/stdc++.h>*
*using namespace std;*
*#define endl "\n"*
*#define Br cout<<endl*
*#define int long long*
*#define double long double*
*#define all(v) v.begin(),v.end()*
*#define allr(v) v.rbegin(),v.rend()*
*#define PT(x) cout << (x) << endl*
*#define PTT(x) cout << (#x) << " is " << (x) << endl; *
*#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);*
*typedef vector<int> vi;*
*typedef pair<int, int> ii;*
*typedef vector<ii> vii;*
*const int M = 1e9 + 7;*
*const int N = 2e6 + 10;*
*const int IM = 1e15 + 37;*
*const double PI = 3.1415926535897932384;*
*inline void PP(int n) { cout << n << " ";}*
*void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}*
*void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].first << " " << v[i].second << endl;}*
*void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << " " ; cout << endl;}*
*void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}*
*// <=================================================================================================================================*
*// <=================================================================================================================================*
*void fun(){*
* int n,m,x,y;cin>>n>>m>>x>>y;*
* if(y>=x){*
* int row1=(x*ceil((double)m/2))+((y-x)*(m/2));*
* int row2=(x*(m/2))+((y-x)*ceil((double)m/2));*
* int sum1=0,sum2=0;*
* for(int i=0;i<n;i++){*
* if(i%2==0){*
* sum1+=row1;*
* sum2+=row2;*
* }else{*
* sum1+=row2;*
* sum2+=row1;*
* }*
* }*
* cout<<max(sum1,sum2)<<endl;*
* }else{*
* int row1=((0)*ceil((double)m/2))+((y)*(m/2));*
* int row2=((0)*(m/2))+((y)*ceil((double)m/2));*
* int sum1=0,sum2=0;*
* for(int i=0;i<n;i++){*
* if(i%2==0){*
* sum1+=row1;*
* sum2+=row2;*
* }else{*
* sum1+=row2;*
* sum2+=row1;*
* }*
* }*
* cout<<max(sum1,sum2)<<endl;*
* }*
*}*
*signed main() {*
* lets_go*
* int t;*
* t=1;*
*cin >> t;*
* while (t--) { *
* fun(); *
* } *
* *
* *
* return 0;*
*}*