Submission #1543086


Source Code Expand

#include <stdio.h>
#include <algorithm>

int main()
{
  unsigned long long q, h, s, d, total;

  scanf("%lld %lld %lld %lld %lld", &q, &h, &s, &d, &total);

  unsigned long long paid = 0;
  unsigned long long best = 0;
  unsigned long long array[4];
  array[0] = q * 8;
  array[1] = h * 4;
  array[2] = s * 2;
  array[3] = d;

  std::sort(array, array + 3);
  unsigned long long otherbest = array[0];
  if(total > 1)
  {
    std::sort(array, array + 4);
    best = array[0];
  }
    else
  best = otherbest;

  if(best == d && total > 1)
  {
    paid = (total / 2) * d;
    total %= 2;
    if(total == 1)
    {
    if(otherbest == q * 8)
      paid += q * 4;

      else if(otherbest == h * 4)
      paid += h * 2;

      else if(otherbest == s * 2)
      paid += s;
    }
    else
    {
      printf("%lld\n", paid);
      return 0;
    }
  }

  else if(best == q * 8)
    paid = total * (q * 4);

  else if(best == h * 4)
    paid = total * (h * 2);

  else if(best == s * 2)
    paid = total * s;

  printf("%lld\n", paid);
  return 0;
}

Submission Info

Submission Time
Task A - Ice Tea Store
User ericzhou
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1102 Byte
Status AC
Exec Time 1 ms
Memory 128 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:8:60: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld %lld %lld", &q, &h, &s, &d, &total);
                                                            ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 23
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 128 KB
sample_02.txt AC 1 ms 128 KB
sample_03.txt AC 1 ms 128 KB
sample_04.txt AC 1 ms 128 KB
subtask_1_01.txt AC 1 ms 128 KB
subtask_1_02.txt AC 1 ms 128 KB
subtask_1_03.txt AC 1 ms 128 KB
subtask_1_04.txt AC 1 ms 128 KB
subtask_1_05.txt AC 1 ms 128 KB
subtask_1_06.txt AC 1 ms 128 KB
subtask_1_07.txt AC 1 ms 128 KB
subtask_1_08.txt AC 1 ms 128 KB
subtask_1_09.txt AC 1 ms 128 KB
subtask_1_10.txt AC 1 ms 128 KB
subtask_1_11.txt AC 1 ms 128 KB
subtask_1_12.txt AC 1 ms 128 KB
subtask_1_13.txt AC 1 ms 128 KB
subtask_1_14.txt AC 1 ms 128 KB
subtask_1_15.txt AC 1 ms 128 KB