/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 11ms 536.0 KiB
#2 Accepted 11ms 536.0 KiB
#3 Accepted 11ms 544.0 KiB
#4 Accepted 11ms 540.0 KiB
#5 Accepted 11ms 532.0 KiB
#6 Accepted 11ms 540.0 KiB
#7 Accepted 11ms 540.0 KiB
#8 Accepted 11ms 536.0 KiB
#9 Accepted 10ms 536.0 KiB
#10 Accepted 11ms 540.0 KiB
#11 Accepted 11ms 544.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,a,b,c,n;
    cin>>x>>a>>b>>c>>n;

    int result = 1e9;

    for(int i=0; i<=200; i++)
    {
        for(int j=0; j<=200; j++)
        {
            for(int k=0; k<=200; k++)
            {
                if(x+(i*a)+(j*b)+(k*c)==n)
                {
                    result = min(result,(i+j+k));
                }
            
            }
        }
    }
    if(result != 1e9)
    {
        cout<<"YES"<<endl;
        cout<<result<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1028 Magical box and spell
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-12 08:34:40
Judged At
2024-10-03 13:59:42
Judged By
Score
100
Total Time
11ms
Peak Memory
544.0 KiB