답안 #1004020

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1004020 2024-06-21T01:00:10 Z De3b0o Copy and Paste 3 (JOI22_copypaste3) C++14
6 / 100
8 ms 476 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;
ll ans;
ll dp[2509];

ll solve(ll x)
{
    if(dp[x])
        return dp[x];
    ll mn = x*A;
    for(int i = 1 ; x>i ; i++)
    {
        ll ans1 = solve(i) + B + (x/i)*C + solve(x%i);
        mn=min(ans1,mn);
    }
    dp[x]=mn;
    return dp[x];
}

int main()
{
    d3
    cin >> n;
    cin >> s;
    cin >> A >> B >> C;
    /*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;
    }*/
    solve(n);
    ans=dp[n];
    if(n==3)
    {
        ans=3*A;
        if(s[0]==s[1]&&s[1]==s[2])
            ans=min(ans,A+B+3*C);
        else if(s[0]==s[1]||s[1]==s[2]||s[0]==s[2])
            ans=min(ans,2*A+B+2*C);
    }
    cans
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 4 ms 348 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 6 ms 348 KB Output is correct
6 Correct 6 ms 472 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
8 Correct 7 ms 476 KB Output is correct
9 Correct 8 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 4 ms 348 KB Output is correct
14 Correct 5 ms 348 KB Output is correct
15 Correct 6 ms 348 KB Output is correct
16 Correct 6 ms 472 KB Output is correct
17 Correct 8 ms 348 KB Output is correct
18 Correct 7 ms 476 KB Output is correct
19 Correct 8 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Incorrect 0 ms 348 KB Output isn't correct
29 Halted 0 ms 0 KB -