답안 #53448

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
53448 2018-06-30T04:42:25 Z 시제연(#2016) Garage (IOI09_garage) C++11
40 / 100
4 ms 724 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 100, M = 2000;

int n, m, a[N], c[N], w[M], p[M], r;
queue<int> q;

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++) scanf("%d", a + i);
    for(int i = 0; i < m; i++) scanf("%d", w + i);
    for(m *= 2; m--; ){
        int x;
        scanf("%d", &x);
        if(x < 0){
            x *= -1; x--;
            c[p[x]] = 0;
            if(!q.empty()){
                c[p[x]] = 1;
                r += a[p[x]] * w[q.front()];
                q.pop();
            }
        }
        else{
            x--;
            int s = 0;
            for(int i = 0; i < n; i++){
                if(!c[i]){
                    c[i] = 1;
                    p[x] = i;
                    r += a[i] * w[x];
                    s = 1;
                    break;
                }
            }
            if(!s) q.push(x);
        }
    }
    printf("%d\n", r);
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
garage.cpp:11:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 0; i < n; i++) scanf("%d", a + i);
                                ~~~~~^~~~~~~~~~~~~
garage.cpp:12:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 0; i < m; i++) scanf("%d", w + i);
                                ~~~~~^~~~~~~~~~~~~
garage.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x);
         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Incorrect 2 ms 504 KB Output isn't correct
3 Correct 2 ms 512 KB Output is correct
4 Incorrect 2 ms 524 KB Output isn't correct
5 Correct 2 ms 524 KB Output is correct
6 Incorrect 2 ms 524 KB Output isn't correct
7 Correct 2 ms 524 KB Output is correct
8 Incorrect 2 ms 524 KB Output isn't correct
9 Correct 2 ms 524 KB Output is correct
10 Incorrect 2 ms 540 KB Output isn't correct
11 Correct 2 ms 540 KB Output is correct
12 Incorrect 2 ms 540 KB Output isn't correct
13 Correct 3 ms 540 KB Output is correct
14 Incorrect 3 ms 588 KB Output isn't correct
15 Correct 3 ms 588 KB Output is correct
16 Incorrect 3 ms 716 KB Output isn't correct
17 Incorrect 3 ms 724 KB Output isn't correct
18 Incorrect 3 ms 724 KB Output isn't correct
19 Incorrect 4 ms 724 KB Output isn't correct
20 Incorrect 4 ms 724 KB Output isn't correct