Submission #5993713


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N,Y;
  cin >> N >> Y;

  int a1=-1,a2=-1,a3=-1;

  for(int i=0, j=0, k=0; i+j+k<=N && i*10000 + j*5000 + k*1000 <= Y; i++, j=0, k=0){
    for(j=0, k=0; i+j+k<=N && i*10000 + j*5000 + k*1000 <= Y; j++, k=0){
      for(k=0; i+j+k<=N && i*10000 + j*5000 + k*1000 <= Y; k++){

        //cout << i << ' ' << j << ' ' << k << endl;
        if(i*10000 + j*5000 + k*1000 == Y && i+j+k == N){
          a1 = i; a2 = j; a3 = k;
          break;
        }
      }
    }
  }

  cout << a1 << ' ' << a2 << ' ' << a3 << endl;
}

Submission Info

Submission Time
Task ABC085C - Otoshidama
User maki68
Language C++14 (GCC 5.4.1)
Score 300
Code Size 601 Byte
Status
Exec Time 1350 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 a01, a02, a03, a04
All 300 / 300 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 1 ms 256 KB
a02 1 ms 256 KB
a03 8 ms 256 KB
a04 1350 ms 256 KB
b05 1 ms 256 KB
b06 1 ms 256 KB
b07 1 ms 256 KB
b08 28 ms 256 KB
b09 1348 ms 256 KB
b10 28 ms 256 KB
b11 1348 ms 256 KB
b12 29 ms 256 KB
b13 27 ms 256 KB
b14 29 ms 256 KB
b15 1317 ms 256 KB
b16 1193 ms 256 KB
b17 1228 ms 256 KB
b18 1 ms 256 KB
b19 2 ms 256 KB
b20 667 ms 256 KB
b21 29 ms 256 KB
b22 27 ms 256 KB
b23 1272 ms 256 KB
b24 1189 ms 256 KB