# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
134728 | Dilshod_Imomov | Garage (IOI09_garage) | C++17 | 4 ms | 424 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>
# define ll long long
# define fi first
# define se second
# define pb push_back
# define pf push_front
# define For(i, a, b) for( int i = a; i < b; i++ )
# define in insert
# define all(a) a.begin(),a.end()
# define pi pair < int, int >
# define DEBUG
# define readfile(file) freopen ( (file + ".in").c_str(), "r", stdin)
# define writefile(file) freopen ( (file + ".out").c_str(), "w", stdout)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
# define LARGE (1e7)
using namespace std;
void Set_File( string file ){readfile(file);writefile(file);}
int n, m;
queue < int > line;
int car;
ll money;
int main(){
/// Author: _Dilshod_
speed;
cin >> n >> m;
vector < pi > parking(n);
vector < pi > cars(m);
For ( i, 0, n ){
cin >> parking[i].fi;
}
For ( i, 0, m ){
cin >> cars[i].fi;
}
For ( i, 0, 2 * m ){
cin >> car;
if ( car < 0 ){
car *= -1;
parking[cars[car - 1].se].se = 0;
cars[car - 1].se = -1;
}
else {
line.push(car);
}
For ( j, 0, n ){
if ( !line.size() ) {
break;
}
if ( !parking[j].se )
{
parking[j].se = 1;
cars[line.front() - 1].se = j;
money += parking[j].fi * cars[line.front() - 1].fi;
line.pop();
}
}
}
cout << money;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |