Submission #19723846


Source Code Expand

Copy
#include <bits/stdc++.h>
#include <atcoder/all>
#include <string.h>
#include <stdio.h>
using namespace std;
using namespace atcoder;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define nl <<endl
#define cy cout<<"Yes" nl
#define cn cout<<"No" nl
#define co(x) cout<<x nl
#define lp(i,a,b) for(i=a;i<b;i++)
#define lpe(i,a,b) for(i=a;i<=b;i++)

int main(){
    int a,b,x,y;
    int ans=0;
    cin>>a>>b>>x>>y;
    if(a==b){
        ans=x;
    }else if(a>b){
        ans=min(x+(a-b)*y,((a-b)*2-1)*x);
        ans=min(ans,(a-b-1)*x+(a-b)/2*y);
        ans=min(ans,x+(a-b-1)*y);
    }else{
        ans=min(x+(b-a)*y,(1+2*(b-a))*x);
    }
    cout<<ans nl;
    return 0;
}

Submission Info

Submission Time
Task A - Hands
User mun
Language C++ (GCC 9.2.1)
Score 0
Code Size 867 Byte
Status WA
Exec Time 10 ms
Memory 3648 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
WA × 1
AC × 11
WA × 1
Set Name Test Cases
Sample sample.txt, sample_2.txt, sample_3.txt
All 18_18_40_79.txt, 18_18_40_81.txt, 1_100_100_100.txt, 1_100_33_65.txt, 1_100_33_67.txt, 1_100_50_100.txt, 1_100_99_99.txt, 77_7_25_49.txt, 77_7_25_51.txt, sample.txt, sample_2.txt, sample_3.txt
Case Name Status Exec Time Memory
18_18_40_79.txt AC 10 ms 3620 KB
18_18_40_81.txt AC 2 ms 3504 KB
1_100_100_100.txt AC 2 ms 3432 KB
1_100_33_65.txt AC 2 ms 3620 KB
1_100_33_67.txt AC 4 ms 3616 KB
1_100_50_100.txt AC 2 ms 3648 KB
1_100_99_99.txt AC 2 ms 3516 KB
77_7_25_49.txt AC 2 ms 3432 KB
77_7_25_51.txt AC 2 ms 3620 KB
sample.txt WA 4 ms 3488 KB
sample_2.txt AC 2 ms 3616 KB
sample_3.txt AC 2 ms 3512 KB