Submission #76652632


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#include "atcoder/all"
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//using mint=modint998244353;
void solve(){
    long long a,b,x,y;
    cin>>a>>b>>x>>y;
    x=abs(x);
    y=abs(y);
    long long ans=0;
    ans+=min(x,y);
    long long tmp=max(x,y)-min(x,y);
    ans*=2*min(a,b);
    if(min(a,b)*3<=max(a,b)){
        ans+=(tmp/2)*4*min(a,b);
        if(tmp%2==1){
            if(y>x and b>a)ans+=3*a;
            else if(x>y and a>b)ans+=3*b;
            else{
                ans+=min(a,b);
            }
        }
    }
    else{
        ans+=tmp/2*(a+b);
        if(tmp%2==1){
            if(y>x)ans+=b;
            else ans+=a;
        }
    }
    cout<<ans<<endl;
}
int main(){
    ios::sync_with_stdio(false);
	cin.tie(nullptr);
    int t=1;
    cin>>t;
    while(t--)solve();
}

Submission Info

Submission Time
Task E - Alternating Costs
User itoito1234
Language C++23 (GCC 15.2.0)
Score 450
Code Size 901 Byte
Status AC
Exec Time 124 ms
Memory 4520 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 1
AC × 33
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 01_handmade_10.txt, 01_handmade_11.txt, 01_handmade_12.txt, 01_handmade_13.txt, 01_handmade_14.txt, 01_handmade_15.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3612 KiB
01_handmade_00.txt AC 100 ms 3516 KiB
01_handmade_01.txt AC 100 ms 3612 KiB
01_handmade_02.txt AC 100 ms 3612 KiB
01_handmade_03.txt AC 100 ms 3484 KiB
01_handmade_04.txt AC 100 ms 3560 KiB
01_handmade_05.txt AC 104 ms 3620 KiB
01_handmade_06.txt AC 105 ms 3620 KiB
01_handmade_07.txt AC 111 ms 3484 KiB
01_handmade_08.txt AC 108 ms 3612 KiB
01_handmade_09.txt AC 107 ms 3484 KiB
01_handmade_10.txt AC 108 ms 3612 KiB
01_handmade_11.txt AC 108 ms 3560 KiB
01_handmade_12.txt AC 108 ms 3652 KiB
01_handmade_13.txt AC 111 ms 3432 KiB
01_handmade_14.txt AC 113 ms 3480 KiB
01_handmade_15.txt AC 119 ms 4520 KiB
02_random_00.txt AC 124 ms 4264 KiB
02_random_01.txt AC 123 ms 4268 KiB
02_random_02.txt AC 123 ms 4268 KiB
02_random_03.txt AC 122 ms 4264 KiB
02_random_04.txt AC 117 ms 3516 KiB
02_random_05.txt AC 118 ms 3652 KiB
02_random_06.txt AC 117 ms 3620 KiB
02_random_07.txt AC 116 ms 3516 KiB
02_random_08.txt AC 122 ms 4260 KiB
02_random_09.txt AC 123 ms 4268 KiB
02_random_10.txt AC 123 ms 4264 KiB
02_random_11.txt AC 124 ms 4268 KiB
02_random_12.txt AC 121 ms 4264 KiB
02_random_13.txt AC 122 ms 4268 KiB
02_random_14.txt AC 124 ms 4264 KiB
02_random_15.txt AC 124 ms 4264 KiB