제출 #1088669

#제출 시각아이디문제언어결과실행 시간메모리
1088669StefanSebezGarage (IOI09_garage)C++14
100 / 100
2 ms424 KiB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
int main(){
    int n,m;scanf("%i%i",&n,&m);
    int a[n+10];for(int i=1;i<=n;i++) scanf("%i",&a[i]);
    int b[m+10];for(int i=1;i<=m;i++) scanf("%i",&b[i]);
    int q=2*m;
    queue<int>kju;
    int res=0;
    int broj[n+10]={0};
    while(q--){
		//for(int i=1;i<=n;i++) printf("%i ",broj[i]);printf("\n");
		int j;scanf("%i",&j);
		if(j>0){
			bool bul=false;
			for(int i=1;i<=n;i++){
				if(!broj[i]){
					res+=a[i]*b[j];
					broj[i]=j;
					bul=true;
					break;
				}
			}
			if(!bul) kju.push(j);
		}
		else{
			j=-j;
			bool bul=false;
			for(int i=1;i<=n;i++){
				if(!broj[i]) bul=true;
				if(broj[i]==j){
					broj[i]=0;
				}
			}
			if(!bul && kju.size()){
				j=kju.front();kju.pop();
				for(int i=1;i<=n;i++){
					if(!broj[i]){
						res+=a[i]*b[j];
						broj[i]=j;
						bul=true;
						break;
					}
				}
			}
		}
    }
    printf("%i\n",res);
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

garage.cpp: In function 'int main()':
garage.cpp:9:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     int n,m;scanf("%i%i",&n,&m);
      |             ~~~~~^~~~~~~~~~~~~~
garage.cpp:10:44: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     int a[n+10];for(int i=1;i<=n;i++) scanf("%i",&a[i]);
      |                                       ~~~~~^~~~~~~~~~~~
garage.cpp:11:44: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     int b[m+10];for(int i=1;i<=m;i++) scanf("%i",&b[i]);
      |                                       ~~~~~^~~~~~~~~~~~
garage.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   int j;scanf("%i",&j);
      |         ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...