답안 #733927

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
733927 2023-05-01T12:05:40 Z vjudge1 Garage (IOI09_garage) C++
100 / 100
3 ms 340 KB
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long s=0;
	int n,m,k=0,p=0,q=0;
	cin>>n>>m;
	int a[n][2],c[m], l[m*2],w[m];
	for(int i=0; i<n; i++)
	{
	cin>>a[i][0]; a[i][1]=0; 
    }
	for(int j=0; j<m; j++)
	cin>>c[j];
	int j=0;
	for(int i=0; i<m*2; i++)
	cin>>l[i];
    
    for(int i=0; i<m*2; i++)
    {
    	if(l[i]>0)
    	{
    		if(k>=n)
    		{
    			w[p]=l[i]; p++;
			}
			else{
				for(int j=0; j<n; j++)
    	    {
    		if(a[j][1]==0) {
    			a[j][1]=l[i]; s+=c[l[i]-1]*a[j][0]; k++; break;
			}
		    }
			}
	    }
	    else {
	    	int x=abs(l[i]);
	    	for(int j=0; j<n; j++)
    	    {
    		if(a[j][1]==x) {
    			if(p>q) {
    				a[j][1]=w[q]; s+=a[j][0]*c[w[q]-1]; q++;
				}
				else {
				a[j][1]=0; k--;}  break;
			}
			
		   }
		}
	}
	cout<<s;
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:15:6: warning: unused variable 'j' [-Wunused-variable]
   15 |  int j=0;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 320 KB Output is correct
17 Correct 2 ms 324 KB Output is correct
18 Correct 2 ms 212 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct