Submission #76658446


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll T,a,b,x,y,k,w,ans;
int main(){
	cin>>T;
	while(T--){
		cin>>a>>b>>x>>y,ans=0;
		if(a>b) swap(a,b),swap(x,y);
		x=abs(x),y=abs(y);
		k=min(x,y);
		ans+=2*a*k,x-=k,y-=k;
		if(3*a<b) b=3*a;
		if(x>0) ans+=x/2*b+(x-x/2)*a;
		if(y>0) ans+=y/2*a+(y-y/2)*b;
		cout<<ans<<endl;
	}
}

Submission Info

Submission Time
Task E - Alternating Costs
User Rya_
Language C++23 (GCC 15.2.0)
Score 450
Code Size 360 Byte
Status AC
Exec Time 267 ms
Memory 4524 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 3468 KiB
01_handmade_00.txt AC 147 ms 3604 KiB
01_handmade_01.txt AC 148 ms 3604 KiB
01_handmade_02.txt AC 147 ms 3484 KiB
01_handmade_03.txt AC 148 ms 3384 KiB
01_handmade_04.txt AC 148 ms 3384 KiB
01_handmade_05.txt AC 181 ms 3604 KiB
01_handmade_06.txt AC 181 ms 3624 KiB
01_handmade_07.txt AC 217 ms 3424 KiB
01_handmade_08.txt AC 198 ms 3604 KiB
01_handmade_09.txt AC 197 ms 3624 KiB
01_handmade_10.txt AC 198 ms 3424 KiB
01_handmade_11.txt AC 198 ms 3408 KiB
01_handmade_12.txt AC 198 ms 3476 KiB
01_handmade_13.txt AC 232 ms 3484 KiB
01_handmade_14.txt AC 232 ms 3484 KiB
01_handmade_15.txt AC 267 ms 4524 KiB
02_random_00.txt AC 263 ms 4260 KiB
02_random_01.txt AC 263 ms 4268 KiB
02_random_02.txt AC 263 ms 4268 KiB
02_random_03.txt AC 263 ms 4268 KiB
02_random_04.txt AC 234 ms 3624 KiB
02_random_05.txt AC 234 ms 3564 KiB
02_random_06.txt AC 234 ms 3604 KiB
02_random_07.txt AC 235 ms 3484 KiB
02_random_08.txt AC 261 ms 4264 KiB
02_random_09.txt AC 262 ms 4268 KiB
02_random_10.txt AC 263 ms 4264 KiB
02_random_11.txt AC 262 ms 4264 KiB
02_random_12.txt AC 263 ms 4268 KiB
02_random_13.txt AC 262 ms 4268 KiB
02_random_14.txt AC 262 ms 4268 KiB
02_random_15.txt AC 261 ms 4260 KiB