Submission #852868

#TimeUsernameProblemLanguageResultExecution timeMemory
852868hngwlogRobots (IOI13_robots)C++14
100 / 100
2453 ms17044 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; #define fi first #define se second #define _size(x) (int)x.size() #define BIT(i, x) ((x >> i) & 1) #define MASK(n) ((1 << n) - 1) #define REP(i, n) for (int i = 0, _n = (n); i < _n; i++) #define FOR(i, a, b) for (int i = a, _b = (b); i <= _b; i++) #define FORD(i, a, b) for (int i = a, _b = (b); i >= _b; i--) #define FORB1(i, mask) for (int i = mask; i > 0; i ^= i & - i) #define FORB0(i, n, mask) for (int i = ((1 << n) - 1) ^ mask; i > 0; i ^= i & - i) #define FORALL(i, a) for (auto i: a) #define fastio ios_base::sync_with_stdio(0); cin.tie(0); int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) { sort(x, x + a); sort(y, y + b); int l = 0; int r = t + 1; while (l < r) { int mid = (l + r) / 2; vector<int> ids, used(t); REP(i, t) ids.push_back(i); sort(ids.begin(), ids.end(), [&] (const int i, int j) { return w[i] < w[j]; }); priority_queue<pair<int, int>> pq; int j = 0; REP(i, a) { int value = x[i]; while (j < t && w[ids[j]] < value) pq.push({s[ids[j]], ids[j++]}); int cnt = 0; while (!pq.empty() && cnt < mid) { int id = pq.top().se; pq.pop(); used[id]++; cnt++; } } vector<int> g; REP(i, t) if (!used[i]) g.push_back(s[i]); sort(g.begin(), g.end()); j = 0; REP(i, b) { int value = y[i], cnt = 0; while (j < _size(g) && cnt < mid && g[j] < value) { cnt++; j++; } } if (j == _size(g)) r = mid; else l = mid + 1; } return (l > t ? - 1 : l); }

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:33:73: warning: operation on 'j' may be undefined [-Wsequence-point]
   33 |             while (j < t && w[ids[j]] < value) pq.push({s[ids[j]], ids[j++]});
      |                                                                        ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...