AtCoder Grand Contest 019

Submission #1540291

Source codeソースコード

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
using namespace std;
typedef long long LL;
const int N = 1e6+7 , INF = 0x3f3f3f3f , mz = 1e9+7;
const double PI = acos(0.0) * 2;
template<typename T1>
T1 gcd(T1 a , T1 b){ return b ? gcd(b,a%b) : a;}

int q[6],p[6],r[6],n;
bool cmp(const int a,const int b){
    return 1.0*q[a]/p[a] < 1.0*q[b]/p[b];
}

int main(){
#ifdef LOCAL
    freopen("F:\\c++\\in.txt", "r", stdin);
//  freopen("F:\\c++\\out1.txt","w",stdout);
#endif

    for(int i = 1 ; i <= 4 ; i++){
        scanf("%d",q+i);
        p[i] = i == 1 ? 1 : p[i-1] * 2;
        r[i] = i;
    }
    sort(r+1,r+5,cmp);
    scanf("%d",&n);
    n<<=2;
    LL ans = 0;
    for(int i = 1 ; n && i < 5 ; i++ ){
        //printf("r[i] = %d , n = %d , p[r] = %d\n",r[i],n,p[r[i]]);
        if( n >= p[r[i]] ){
            LL cnt = n / p[r[i]];
            ans += cnt * q[r[i]];
            n -= cnt * p[r[i]];
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Submission

Task問題 A - Ice Tea Store
User nameユーザ名 low_and_up
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1139 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:30:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",q+i);
^
./Main.cpp:35:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt,sample_04.txt
All 0 / 300 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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 WA
subtask_1_03.txt WA
subtask_1_04.txt AC 1 ms 256 KB
subtask_1_05.txt WA
subtask_1_06.txt AC 1 ms 256 KB
subtask_1_07.txt AC 1 ms 256 KB
subtask_1_08.txt WA
subtask_1_09.txt WA
subtask_1_10.txt AC 1 ms 256 KB
subtask_1_11.txt WA
subtask_1_12.txt WA
subtask_1_13.txt WA
subtask_1_14.txt WA
subtask_1_15.txt WA