| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 151069 | youssefbou62 | Garage (IOI09_garage) | C++14 | 5 ms | 416 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab (int x ) { return (x>0?x:-x); }
const int N = 1e4+5 ;
int w[N],rates[105],pos[105];
ll ans ;
int main(){
int n , m ;
cin >> n >> m ;
for(int i = 1 ; i <= n ; i++ )cin >> rates[i];
for(int i = 1 ; i <= m ; i++ )cin >> w[i] ;
int ans = 0 ;
queue<int> q;
for(int t = 0 ; t < 2*m ; t ++ ){
int c , car ;
cin >> c ;
car = abs(c) ;
if( c > 0){
int P = -1 ;
for(int i = 1 ; i <= n ; i++ ){
if( !pos[i] ){
P = i ;
break ;
}
}
if( P == -1 )q.push(c);
else pos[P] = c,ans += (w[c]*rates[P])*1LL;
}else{
for(int i = 1 ; i <= n ; i++ ){
if( pos[i] == car ){
pos[i] = 0 ;
break ;
}
}
int P = -1 ;
for(int i = 1 ; i <= n ; i++ ){
if( !pos[i] ){
P = i ;
break ;
}
}
if( !q.empty() && P != -1 ){
pos[P]=q.front();
ans += (w[q.front()]*rates[P])*1LL;
q.pop() ;
}
}
}
cout << ans << endl;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
