제출 #152323

#제출 시각아이디문제언어결과실행 시간메모리
152323mielloGarage (IOI09_garage)C++11
100 / 100
3 ms380 KiB
#include <bits/stdc++.h> #define mkp make_pair #define pb push_back #define emb emplace_back #define em emplace #define ii pair<int,int> #define iii pair<int ,ii> #define f first #define s second #define all(x) x.begin(),x.end() #define allc(x) x.begin(),x.end(),cmp #define optimizar_io ios_base::sync_with_stdio(false);cin.tie(NULL); using namespace std; const int INF = 0x3f3f3f3f; const int MXN = 2005; int cost[MXN] , w[MXN] , l[MXN]; bool chk[MXN]; queue<int> q; int main(){ int n , m; scanf("%d %d",&n,&m); for(int i = 1 ; i <= n ; i++){ scanf("%d",&cost[i]); } for(int i = 1 ; i <= m ; i++){ scanf("%d",&w[i]); } int ans = 0; for(int i = 0 ; i < 2 * m ; i++){ int x; scanf("%d",&x); if(x < 0){ x = abs(x); // printf("%d %d %d\n",x,cost[l[x]] , l[x]); ans += cost[l[x]] * w[x]; chk[l[x]] = 0; if(q.size()){ int u = q.front(); chk[l[x]] = 1; l[u] = l[x]; q.pop(); } }else{ bool non = 0; for(int j = 1 ; j <= n ; j++){ if(!chk[j]){ non = 1; chk[j] = 1; l[x] = j; break; } } if(!non){ q.push(x); } } } printf("%d",ans); }

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

garage.cpp: In function 'int main()':
garage.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~
garage.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&cost[i]);
         ~~~~~^~~~~~~~~~~~~~~
garage.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&w[i]);
         ~~~~~^~~~~~~~~~~~
garage.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&x);
         ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...