| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 232926 | Zex | Garage (IOI09_garage) | C++11 | 5 ms | 384 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 | 
|---|---|---|---|---|
| Fetching results... | ||||
