답안 #758912

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
758912 2023-06-15T13:54:33 Z akarinkof Garage (IOI09_garage) C++14
5 / 100
2 ms 468 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P1;
typedef pair<pair<ll,ll>,ll> P3;
typedef pair<string,ll> Ps;
typedef pair<pair<ll,ll>,pair<ll,ll> > P4;


#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,s,e) for(ll i=s;i<=e;++i)
#define FFOR(i,s,e) for(ll i=s;i>=e;--i)

#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define ALL(a) (a).begin(),(a).end()
#define mp make_pair
#define pb push_back
#define vl vector<ll>
#define vs vector<string>
#define so(a) sort(a.begin(),a.end())

#define fi first
#define se second
#define print(a) cout<<a<<endl
#define ssize(a) (ll)(a.size())

#define MAX_N 1002
#define i197 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


const ll INF=1000000000000000001;
struct edge
{
	int to, cost;
};

struct pos{
	// 1 変数を入れる;
	ll t;
	ll x,y;
	set<ll> st;

};
int dx[4] = { 1, 0, -1, 0};
int dy[4] = { 0, 1, 0, -1};
int dd[5] = { 0, 1, 0, -1, 0};





int main(){

	ll n,m;
	cin>>n>>m;

	vl r(n);
	rep(i,n)cin>>r[i];

	vl w(m+1);
	rep(i,m)cin>>w[i+1];

	priority_queue<ll,vector<ll>,greater<ll> > que;
	rep(i,n)que.push(i);

	vl v(n);
	ll ans=0;
	rep(i,2*m){
		ll c;
		cin>>c;

		if(c>0){
			ans+=r[que.top()]*w[c];
			v[c]=que.top();
			que.pop();
		}else{
			que.push(v[abs(c)]);
		}

	}
	print(ans);

	return 0;

}














# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Runtime error 1 ms 428 KB Execution killed with signal 6
3 Correct 1 ms 212 KB Output is correct
4 Runtime error 1 ms 424 KB Execution killed with signal 6
5 Runtime error 1 ms 340 KB Execution killed with signal 6
6 Runtime error 1 ms 340 KB Execution killed with signal 6
7 Runtime error 1 ms 340 KB Execution killed with signal 6
8 Runtime error 1 ms 340 KB Execution killed with signal 6
9 Runtime error 1 ms 340 KB Execution killed with signal 6
10 Runtime error 1 ms 428 KB Execution killed with signal 6
11 Runtime error 2 ms 428 KB Execution killed with signal 6
12 Runtime error 1 ms 468 KB Execution killed with signal 6
13 Runtime error 1 ms 468 KB Execution killed with signal 6
14 Runtime error 1 ms 340 KB Execution killed with signal 6
15 Runtime error 1 ms 468 KB Execution killed with signal 6
16 Runtime error 2 ms 468 KB Execution killed with signal 6
17 Runtime error 2 ms 468 KB Execution killed with signal 6
18 Runtime error 2 ms 468 KB Execution killed with signal 6
19 Runtime error 2 ms 468 KB Execution killed with signal 6
20 Runtime error 2 ms 468 KB Execution killed with signal 6