답안 #1094823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094823 2024-09-30T15:59:42 Z salmon Garage (IOI09_garage) C++14
45 / 100
1 ms 604 KB
#include <bits/stdc++.h>
using namespace std;

int N;
int M;
int R[110];
set<int> sat;
int inv[110];
int tim[110];
int W[2100];
int x;
queue<int> q;

int main(){

    scanf(" %d",&N);
    scanf(" %d",&M);

    for(int i = 0; i < N; i++){
        scanf(" %d",&R[i]);
        sat.insert(i);
    }

    for(int i = 1; i <= M; i++){
        inv[i] = -1;
        scanf(" %d",&W[i]);
    }

    long long int ans = 0;

    for(int i = 0; i < M * 2; i ++){
        scanf(" %d",&x);

        if(x < 0){
            x = -x;
            sat.insert(inv[x]);
            ans += R[inv[x]]  * W[x];
            if(!q.empty()){
                x = q.front();
                q.pop();
            }
            else x = -1;
        }

        if(x > 0){
            if(sat.empty()){
                q.push(x);
                continue;
            }
            int l = *sat.begin();
            sat.erase(sat.begin());
            tim[l] = i;
            inv[x] = l;
        }
    }

    printf("%lld",ans);
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf(" %d",&N);
      |     ~~~~~^~~~~~~~~~
garage.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf(" %d",&M);
      |     ~~~~~^~~~~~~~~~
garage.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf(" %d",&R[i]);
      |         ~~~~~^~~~~~~~~~~~~
garage.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         scanf(" %d",&W[i]);
      |         ~~~~~^~~~~~~~~~~~~
garage.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         scanf(" %d",&x);
      |         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 444 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Runtime error 0 ms 348 KB Execution killed with signal 11
11 Runtime error 1 ms 348 KB Execution killed with signal 11
12 Runtime error 1 ms 348 KB Execution killed with signal 11
13 Runtime error 0 ms 348 KB Execution killed with signal 11
14 Runtime error 1 ms 604 KB Execution killed with signal 11
15 Runtime error 1 ms 348 KB Execution killed with signal 11
16 Runtime error 0 ms 348 KB Execution killed with signal 11
17 Runtime error 1 ms 348 KB Execution killed with signal 11
18 Runtime error 1 ms 348 KB Execution killed with signal 11
19 Runtime error 0 ms 348 KB Execution killed with signal 11
20 Runtime error 0 ms 348 KB Execution killed with signal 11