답안 #522414

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
522414 2022-02-04T22:58:53 Z nurlitadf Garage (IOI09_garage) C++17
5 / 100
2 ms 460 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll modexp(ll b, ll e, ll m){
    ll r = 1;
    while(e > 0){
     if((e & 1) == 1){
         r = (r * b) % m;
     }
     e >>= 1;
     b = (b * b) % m;
    }
    return r;
}

bool isvowel(char ch) { 
    return (ch == 'a') || (ch == 'e') ||(ch == 'i') ||(ch == 'o') ||(ch == 'u') ||(ch == 'y'); 
}

int main() {
    int n, m;
    cin >> n >> m;

    vector<int> rates;
    for(int i = 0; i < n; i++) {
        int v;
        cin >> v;

        rates.push_back(v);
    }

    vector<int> cars;
    for(int i = 0; i < m; i++) {
        int v;
        cin >> v;

        cars.push_back(v);
    }

    vector<int> space(n, -1);
    vector<int> car_to_space(n, -1);
    ll ans = 0;
    queue<int> q;

    for(int i = 0; i < m * 2; i++) {
        int v;
        cin >> v;

        if(v > 0) {
            v--;
            bool found = false;
            for(int j = 0; j < n; j++) {
                if(space[j] == -1) {
                    space[j] = v;
                    car_to_space[v] = j;

                    ans += rates[j] * cars[v];
                    found = true;
                    // cout << "~~~ " << v << " " << j << endl;
                    break;
                }
            }

        } else {
            v = abs(v) - 1;
            int s = car_to_space[v];
            space[s] = -1;
            car_to_space[v] = -1;
        }
    }

    cout << ans << endl;

    return 0;
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:52:18: warning: variable 'found' set but not used [-Wunused-but-set-variable]
   52 |             bool found = false;
      |                  ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 6
2 Incorrect 1 ms 204 KB Output isn't correct
3 Correct 1 ms 204 KB Output is correct
4 Runtime error 1 ms 332 KB Execution killed with signal 6
5 Runtime error 1 ms 332 KB Execution killed with signal 6
6 Runtime error 1 ms 332 KB Execution killed with signal 6
7 Runtime error 1 ms 332 KB Execution killed with signal 6
8 Runtime error 1 ms 332 KB Execution killed with signal 6
9 Runtime error 1 ms 332 KB Execution killed with signal 6
10 Runtime error 1 ms 332 KB Execution killed with signal 11
11 Runtime error 1 ms 332 KB Execution killed with signal 6
12 Runtime error 1 ms 332 KB Execution killed with signal 6
13 Runtime error 1 ms 332 KB Execution killed with signal 6
14 Runtime error 1 ms 460 KB Execution killed with signal 6
15 Runtime error 1 ms 344 KB Execution killed with signal 6
16 Runtime error 2 ms 460 KB Execution killed with signal 6
17 Runtime error 2 ms 460 KB Execution killed with signal 6
18 Runtime error 2 ms 460 KB Execution killed with signal 11
19 Runtime error 2 ms 460 KB Execution killed with signal 11
20 Runtime error 2 ms 460 KB Execution killed with signal 6