Submission #232926

# Submission time Handle Problem Language Result Execution time Memory
232926 2020-05-18T16:50:07 Z Zex Garage (IOI09_garage) C++11
100 / 100
5 ms 384 KB
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define INF INT_MAX
#define LD long double
#define endl '\n'
#define output for(LL i=0;i<sizex;i++) { for(LL j=0;j<sizey;j++) { cout << A[i][j] << " "; }cout<<endl; }cout<<endl;

const int maxN = 101, maxM = 2001;
int N, M;
int RATE[maxN];
int WEIGHT[maxM];
bool TAKEN[maxN] = {};
int takenSpace[maxM] = {};
int takenSpaces = 0;
int PROFIT = 0;
queue <int> q;

void enter( int car ){

    if( takenSpaces == N ) return q.push(car);

    for(int i=1;i<=N;i++){
        if( TAKEN[i] ) continue;
        takenSpace[car] = i;
        TAKEN[i] = true;
        PROFIT += RATE[i]*WEIGHT[car];
        takenSpaces++;
        // cout << "Car " << car << " entered in lane " << i << "(" << RATE[i]*WEIGHT[car] << ")" << endl;
        return;
    }

    cout << "uhhh brat?" << endl;

}

void leave( int car ){

    if( !takenSpace[car] ){
        cout << "uhhh brat?" << endl; return;
    }

    takenSpaces--;
    TAKEN[takenSpace[car]] = false;
    // cout << "Car " << car << " left lane " << takenSpace[car] << endl;
    takenSpace[car] = 0;

    while( takenSpaces < N && !q.empty() ){
        enter( q.front() );
        q.pop();
    }

}

int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    cin >> N >> M;

    for(int i=1;i<=N;i++) cin >> RATE[i];

    for(int i=1;i<=M;i++) cin >> WEIGHT[i];

    for(int i=0;i<2*M;i++){

        int CAR; cin >> CAR;

        if( CAR < 0 ) leave( -CAR );
        else          enter( CAR );

    }

    cout << PROFIT << endl;

}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct