Submission #1545689
Source Code Expand
#include <bits/stdc++.h> using namespace std; int main(void) { int64_t n; int a[4]; pair <int, int> b[4]; for (int i = 0; i < 4; i++) { scanf("%d", &a[i]); b[i].first = a[i] << (3 - i); b[i].second = i; } sort(b, b + 4); scanf("%lld", &n); n *= 4; int64_t ans = 0; while (n) { if (n <= 4 && b[0].second == 3) { ans += a[b[1].second]; n -= 1 << b[1].second; } else { int div = 1 << b[0].second; ans += n / div * a[b[0].second]; n %= div; } } printf("%lld\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Ice Tea Store |
User | SiuGinHung |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 676 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:15:21: warning: format ‘%lld’ expects argument of type ‘long long int*’, but argument 2 has type ‘int64_t* {aka long int*}’ [-Wformat=] scanf("%lld", &n); ^ ./Main.cpp:29:25: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘int64_t {aka long int}’ [-Wformat=] printf("%lld\n", ans); ^ ./Main.cpp:10:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &a[i]); ^ ./Main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld", &n); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
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 | 256 KB |
sample_02.txt | AC | 1 ms | 256 KB |
sample_03.txt | AC | 1 ms | 256 KB |
sample_04.txt | AC | 1 ms | 256 KB |
subtask_1_01.txt | AC | 1 ms | 256 KB |
subtask_1_02.txt | AC | 1 ms | 256 KB |
subtask_1_03.txt | AC | 1 ms | 256 KB |
subtask_1_04.txt | AC | 1 ms | 256 KB |
subtask_1_05.txt | AC | 1 ms | 256 KB |
subtask_1_06.txt | AC | 1 ms | 256 KB |
subtask_1_07.txt | AC | 1 ms | 256 KB |
subtask_1_08.txt | AC | 1 ms | 256 KB |
subtask_1_09.txt | AC | 1 ms | 256 KB |
subtask_1_10.txt | AC | 1 ms | 256 KB |
subtask_1_11.txt | AC | 1 ms | 256 KB |
subtask_1_12.txt | AC | 1 ms | 256 KB |
subtask_1_13.txt | AC | 1 ms | 256 KB |
subtask_1_14.txt | AC | 1 ms | 256 KB |
subtask_1_15.txt | AC | 1 ms | 256 KB |