답안 #1088668

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1088668 2024-09-14T18:34:20 Z StefanSebez Garage (IOI09_garage) C++14
0 / 100
27 ms 2116 KB
#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;
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:17:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   17 |   for(int i=1;i<=n;i++) printf("%i ",broj[i]);printf("\n");
      |   ^~~
garage.cpp:17:47: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   17 |   for(int i=1;i<=n;i++) printf("%i ",broj[i]);printf("\n");
      |                                               ^~~~~~
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);
      |         ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Incorrect 1 ms 348 KB Output isn't correct
11 Incorrect 1 ms 348 KB Output isn't correct
12 Incorrect 2 ms 348 KB Output isn't correct
13 Incorrect 3 ms 348 KB Output isn't correct
14 Incorrect 7 ms 604 KB Output isn't correct
15 Incorrect 7 ms 680 KB Output isn't correct
16 Incorrect 10 ms 860 KB Output isn't correct
17 Incorrect 14 ms 1116 KB Output isn't correct
18 Incorrect 18 ms 1412 KB Output isn't correct
19 Incorrect 27 ms 2116 KB Output isn't correct
20 Incorrect 22 ms 1760 KB Output isn't correct