Submission #7027958


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは 対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    LL Y;cin >> Y;
    int a = -1;
    int b = -1;
    int c = -1;
    LL ans;
    bool ok = false;
    if(1000*N == Y){
        a = 0;
        b = 0;
        c = N;
    }
    else if(5000*N == Y){
        a = 0;
        b = N;
        c = 0;
    }
    else if(10000*N == Y){
        a = N;
        b = 0;
        c = 0;
    }
    else if(1000*N < Y){
        rep(i,N) {
            rep(j,N-i){
                ans = 10000*i + 5000*j + 1000*(N-i-j);
                if(ans == Y){
                    ok = true;
                    a = i;
                    b = j;
                    c = (N-i-j);
                    break;
                }
            }
            if(ok)break;
        }
    }

    cout << a << " " << b << " " << c << endl;
}

Submission Info

Submission Time
Task C - Otoshidama
User kerozou
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1473 Byte
Status AC
Exec Time 3 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 24
Set Name Test Cases
Sample a01, a02, a03, a04
All a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
a04 AC 1 ms 256 KB
b05 AC 1 ms 256 KB
b06 AC 1 ms 256 KB
b07 AC 1 ms 256 KB
b08 AC 1 ms 256 KB
b09 AC 1 ms 256 KB
b10 AC 1 ms 256 KB
b11 AC 3 ms 256 KB
b12 AC 1 ms 256 KB
b13 AC 1 ms 256 KB
b14 AC 1 ms 256 KB
b15 AC 3 ms 256 KB
b16 AC 3 ms 256 KB
b17 AC 3 ms 256 KB
b18 AC 1 ms 256 KB
b19 AC 1 ms 256 KB
b20 AC 1 ms 256 KB
b21 AC 3 ms 256 KB
b22 AC 3 ms 256 KB
b23 AC 3 ms 256 KB
b24 AC 3 ms 256 KB