제출 #752466

#제출 시각아이디문제언어결과실행 시간메모리
752466wenqiGarage (IOI09_garage)C++17
100 / 100
2 ms348 KiB
// trans rights #include <bits/extc++.h> using namespace std; using ll = long long; #ifdef DEBUG #define D(args...) fprintf(stderr, args) #else #define D(...) #endif int N, M; int rate[105], weight[2005]; int spot[105]; int own[2005]; int main(int argc, const char *argv[]) { scanf(" %d %d", &N, &M); for (int i = 1; i <= N; i++) scanf(" %d", &rate[i]); for (int i = 1; i <= M; i++) scanf(" %d", &weight[i]); int sum = 0; queue<int> h; for (int k = 0; k < 2 * M; k++) { int x; scanf(" %d", &x); if (x > 0) { int q = -1; for (int i = 1; i <= N; i++) { if (spot[i] == 0) { q = i; break; } } if (q == -1) { h.push(x); } else { spot[q] = x; sum += weight[x] * rate[q]; own[x] = q; } } else { x = -x; spot[own[x]] = 0; if (h.size()) { int p = h.front(); h.pop(); own[p] = own[x]; spot[own[x]] = p; sum += weight[p] * rate[own[p]]; } } } printf("%d", sum); return 0; }

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

garage.cpp: In function 'int main(int, const char**)':
garage.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  scanf(" %d %d", &N, &M);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
garage.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf(" %d", &rate[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~
garage.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf(" %d", &weight[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
garage.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   scanf(" %d", &x);
      |   ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...