답안 #159744

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
159744 2019-10-24T12:09:01 Z geon040702 주유소 (KOI16_gasM) C++14
100 / 100
34 ms 3332 KB
#include <bits/stdc++.h>
using namespace std;

long long int dist[100010];
long long int gas[100010];
long long int res;
int city;

int main(void)
{
    int i;
    scanf("%d", &city);

    for(i=1;i<city;i++) {
        scanf("%lld", &dist[i]);
    }

    for(i=1;i<=city;i++) {
        scanf("%lld", &gas[i]);
        if(i != 1 && gas[i-1] < gas[i]) {
            gas[i] = gas[i-1];
        }
        if(i < city) {
            res += dist[i] * gas[i];
        }
    }

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

Compilation message

gas.cpp: In function 'int main()':
gas.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &city);
     ~~~~~^~~~~~~~~~~~~
gas.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &dist[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~
gas.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &gas[i]);
         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 2552 KB Output is correct
2 Correct 21 ms 2168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 2552 KB Output is correct
2 Correct 21 ms 2168 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 5 ms 632 KB Output is correct
12 Correct 11 ms 1272 KB Output is correct
13 Correct 34 ms 3332 KB Output is correct
14 Correct 31 ms 3320 KB Output is correct
15 Correct 25 ms 2680 KB Output is correct