제출 #709667

#제출 시각아이디문제언어결과실행 시간메모리
709667DarkMatterGarage (IOI09_garage)C++17
100 / 100
4 ms340 KiB
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int>pi; typedef pair<ll, ll>pl; typedef vector<pi>vpi; typedef vector<pl>vpl; typedef vector<vi> vvi; typedef vector<vl> vvl; typedef vector<string> vs; typedef vector<bool> vb; const long double PI = acos(-1); const int oo = 2e9; const int MOD = 998244353; const int N = 2e5 + 7; #define endl '\n' #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define read(v) for (auto& it : v) scanf("%d", &it); #define readL(v) for (auto& it : v) scanf("%lld", &it); #define print(v) for (auto it : v) printf("%d ", it); puts(""); #define printL(v) for (auto it : v) printf("%lld ", it); puts(""); void solve() { int n, m; scanf("%d %d", &n, &m); vl v(n), w(m); vb vis(n); readL(v); readL(w); queue<ll>q; map<int, int>mp; ll ans = 0; for (int i = 0, x; i < 2 * m; i++) { scanf("%d", &x); if (x > 0) q.push(x); else vis[mp[-x]] = false; while (!q.empty()) { int cur = q.front(); bool ok = false; for (int j = 0; j < n; j++) { if (!vis[j]) { vis[j] = ok = true, mp[cur] = j; ans += v[j] * w[cur - 1]; break; } } if (!ok) break; q.pop(); } } printf("%lld\n", ans); } int t = 1; int main() { //#ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); //#endif //scanf("%d", &t); while (t--) solve(); }

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

garage.cpp: In function 'void solve()':
garage.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |  scanf("%d %d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~
garage.cpp:24:42: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 | #define readL(v) for (auto& it : v) scanf("%lld", &it);
      |                                     ~~~~~^~~~~~~~~~~~~
garage.cpp:32:2: note: in expansion of macro 'readL'
   32 |  readL(v);
      |  ^~~~~
garage.cpp:24:42: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 | #define readL(v) for (auto& it : v) scanf("%lld", &it);
      |                                     ~~~~~^~~~~~~~~~~~~
garage.cpp:33:2: note: in expansion of macro 'readL'
   33 |  readL(w);
      |  ^~~~~
garage.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |   scanf("%d", &x);
      |   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...