結果

問題 No.842 初詣
ユーザー LayCurseLayCurse
提出日時 2019-06-28 21:24:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,499 bytes
コンパイル時間 2,583 ms
コンパイル使用メモリ 198,340 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 21:33:01
合計ジャッジ時間 2,853 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A;
int B;
int C;
int D;
int E;
int F;
int G;
int main(){
  rd(A);
  rd(B);
  rd(C);
  rd(D);
  rd(E);
  rd(F);
  rd(G);
  while(G >= 500 && A > 0){
    G -= 500;
    A--;
  }
  while(G >= 100 && B > 0){
    G -= 100;
    B--;
  }
  while(G >=  50 && C > 0){
    G -=  50;
    C--;
  }
  while(G >=  10 && D > 0){
    G -=  10;
    D--;
  }
  while(G >=   5 && E > 0){
    G -=   5;
    E--;
  }
  while(G >=   1 && F > 0){
    G -=   1;
    F--;
  }
  if(G==0){
    wt_L("YES");
    wt_L('\n');
  }
  else{
    wt_L("NO");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190626-1

// --- original code ---
// int A, B, C, D, E, F, G;
// {
//   rd(A,B,C,D,E,F,G);
//   while(G >= 500 && A > 0) G -= 500, A--;
//   while(G >= 100 && B > 0) G -= 100, B--;
//   while(G >=  50 && C > 0) G -=  50, C--;
//   while(G >=  10 && D > 0) G -=  10, D--;
//   while(G >=   5 && E > 0) G -=   5, E--;
//   while(G >=   1 && F > 0) G -=   1, F--;
//   wt(if[G==0, "YES", "NO"]);
// }
0