/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 580.0 KiB
#2 Accepted 1ms 580.0 KiB
#3 Accepted 2ms 580.0 KiB
#4 Accepted 4ms 576.0 KiB
#5 Accepted 32ms 724.0 KiB
#6 Accepted 302ms 1.406 MiB
#7 Accepted 304ms 1.539 MiB
#8 Accepted 304ms 1.484 MiB
#9 Accepted 292ms 1.402 MiB
#10 Accepted 2ms 532.0 KiB

Code

#include<bits/stdc++.h>
#define int long long int
#define yes cout << "YES" << endl
#define show(x) cout << x << endl;
#define no cout << "NO" << endl
#define uint unsigned long long int
#define all(v) v.begin(),v.end()
#define print(v) for(auto x : v) cout << x << " "; cout << endl;
int mypow(int a, int b){ int ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
#define init(arr, val) memset(arr, val, sizeof(arr))
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const int M = 1e9+7;
const int N =1e6+10;
vector<bool> is_prime(N+1, true);
void pre_cal_prime(){
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= N; i++) {
        if (is_prime[i]) {
            for (int j = i * i; j <= N; j += i)
                is_prime[j] = false;
        }
    }    
}

bool isSubSeq(string s1,string s2)
{
    int m = s1.length(), n = s2.length();
    if (m > n) return false;
    int i = 0, j = 0;
    while (i < m && j < n) {
        if (s1[i] == s2[j])
            i++;
        j++;
    }
    return i == m;
}

void swap(int& x, int& y) 
{ 
    int temp = x; 
    x = y; 
    y = temp; 
} 

// Function to find the possible 
// permutations 
void permutations(vector<vector<int> >& res, 
                vector<int> nums, int l, int h) 
{ 
    // Base case 
    // Add the vector to result and return 
    if (l == h) { 
        res.push_back(nums); 
        return; 
    } 

    // Permutations made 
    for (int i = l; i <= h; i++) { 

        // Swapping 
        swap(nums[l], nums[i]); 

        // Calling permutations for 
        // next greater value of l 
        permutations(res, nums, l + 1, h); 

        // Backtracking 
        swap(nums[l], nums[i]); 
    } 
} 

// Function to get the permutations 
vector<vector<int> > permute(vector<int>& nums) 
{ 
    // Declaring result variable 
    vector<vector<int> > res; 
    int x = nums.size() - 1; 

    // Calling permutations for the first 
    // time by passing l 
    // as 0 and h = nums.size()-1 
    permutations(res, nums, 0, x); 
    return res; 
} 
int binpow(int a, int b) {
    a %= M;
    int res = 1;
    while (b > 0) {
        if (b & 1) res = res * a % M;
        a = a * a % M;
        b >>= 1;
    }
    return res;
}

void blast(int row,int col,vector<vector<int>>&wall){
    if(wall[row][col]){
        wall[row][col] = 0;
    }
    else{
        for(int right=col+1;right<wall[0].size();right++){
            if(wall[row][right]){
                wall[row][right]=0;
                break;
            }
        }

        for(int left=col-1;left>=0;left--){
            if(wall[row][left]){
                wall[row][left]=0;
                break;
            }
        }
        for(int up=row-1;up>=0;up--){
            if(wall[up][col]){
                wall[up][col]=0;
                break;
            }
        }
        for(int down=row+1;row<wall.size();row++){
            if(wall[down][col]){
                wall[down][col]=0;
                break;
            }
        }
    }
}
int gcd(int a,int b)
{
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}
double nthRoot(double x, int n) {
    return powl(x, 1.0 / n);
}
int run = 0;


int32_t main() 
{
    int t; cin >> t;
    while(t--){
        int n,d; cin >> n>> d;
        int a,b; cin >> a >> b;
        int mn = min(n,d);
        int ans = mn*a;
        n-=mn;
        ans+=n*b;
        cout << ans << endl;
    }
}

Information

Submit By
Type
Submission
Problem
P1090 Summer trip
Language
C++20 (G++ 13.2.0)
Submit At
2024-10-02 04:49:43
Judged At
2024-11-11 02:51:46
Judged By
Score
100
Total Time
304ms
Peak Memory
1.539 MiB