답안 #1004017

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1004017 2024-06-21T00:43:41 Z De3b0o Copy and Paste 3 (JOI22_copypaste3) C++14
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*x)
#define rc (2*x+1)

using namespace std;

ll n , A , B , C;
string s;

int main()
{
    d3
    cin >> n;
    cin >> s;
    cin >> A >> B >> C;
    ll ans = n*A;
    ll p;
    for(int i = 0 ; 12>i ; i++)
    {
        ll x = (1<<i);
        if(x>n)
            break;
        if(i==0)
        {
            ll ans1 = A+B + n*C;
            ans=min(ans1,ans);
            p=A;
            continue;
        }
        ll ans1;
        ll c = min(p+B+2*C,p+A*(x/2));
        ans1 = c + B + (n/x)*C;
        ans1 += n%x * A;
        ans=min(ans,ans1);
        p=c;
    }
    cans
}

Compilation message

copypaste3.cpp: In function 'int main()':
copypaste3.cpp:46:21: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   46 |         ll c = min(p+B+2*C,p+A*(x/2));
      |                    ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -