답안 #480161

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
480161 2021-10-15T03:19:38 Z gg123_pe Garage (IOI09_garage) C++17
0 / 100
7 ms 460 KB
#include <bits/stdc++.h> 
using namespace std; 

#define f(i,a,b) for(int i = a; i < b; i++)

int n, m, x, ans, rate[105], w[2005], place[2005], freee;
bool on[105]; 

int main(){
    cin >> n >> m; 
    f(i,1,n+1) cin >> rate[i]; 
    f(i,1,m+1) cin >> w[i]; 

    freee = n; 
    queue <int> q; 
    f(i,0,2*m){
        cin >> x; 
        if(x < 0){
            on[place[-x]] = 0, freee++; 

            if(q.size() == 0) continue; 
            int t = q.front();
            f(j,1,n+1){
                if(!on[j]) {
                    place[x] = j, on[j] = 1, ans += rate[j]*w[t]; 
                    cout << "car " << t << " place " << j << endl; 
                    break; 
                }
            } 
            q.pop(), freee--; 
            continue; 
        }
        else{
            q.push(x); 
            while(!q.empty()){
                if(freee == 0) break; 

                int t = q.front();
                f(j,1,n+1){
                    if(!on[j]) {
                        place[x] = j, on[j] = 1, ans += rate[j]*w[t]; 
                        cout << "car " << t << " place " << j << endl; 
                        break; 
                    }
                } 
                q.pop(), freee--; 
            }
        }
    }

    cout << ans << endl; 
    return 0; 
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:25:28: warning: array subscript -1 is below array bounds of 'int [2005]' [-Warray-bounds]
   25 |                     place[x] = j, on[j] = 1, ans += rate[j]*w[t];
      |                     ~~~~~~~^
garage.cpp:6:39: note: while referencing 'place'
    6 | int n, m, x, ans, rate[105], w[2005], place[2005], freee;
      |                                       ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Incorrect 0 ms 292 KB Output isn't correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Incorrect 1 ms 204 KB Output isn't correct
7 Incorrect 1 ms 204 KB Output isn't correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Incorrect 1 ms 204 KB Output isn't correct
10 Runtime error 1 ms 428 KB Execution killed with signal 6
11 Incorrect 1 ms 204 KB Output isn't correct
12 Runtime error 1 ms 332 KB Execution killed with signal 11
13 Incorrect 2 ms 204 KB Output isn't correct
14 Incorrect 2 ms 332 KB Output isn't correct
15 Incorrect 3 ms 332 KB Output isn't correct
16 Incorrect 4 ms 332 KB Output isn't correct
17 Runtime error 4 ms 460 KB Execution killed with signal 11
18 Runtime error 3 ms 460 KB Execution killed with signal 11
19 Runtime error 2 ms 460 KB Execution killed with signal 11
20 Runtime error 7 ms 460 KB Execution killed with signal 11