Submission #781171

#TimeUsernameProblemLanguageResultExecution timeMemory
781171caganyanmazRobots (IOI13_robots)C++17
90 / 100
150 ms13092 KiB
#include <bits/stdc++.h> using namespace std; #include "robots.h" //#define DEBUGGING void __print(size_t i) { std::cerr << i; } void __print(int i) { std::cerr << i; } void __print(long long int i) { std::cerr << i; } void __print(const char *c) { std::cerr << c; } template<typename T> void __print(T& t) { std::cerr <<"{";int f = 0; for (auto& i : t) { std::cerr << ((f++) ? ", ": ""); __print(i); } std::cerr << "}"; } void _print() { std::cerr << "]\n"; } template<typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) std::cerr << ", "; _print(v...); } #ifdef DEBUGGING #define debug(x...) std::cerr << "[" << (#x) << "] = ["; _print(x) #else #define debug(x...) #endif int ceil_div(int a, int b) { debug(a, b); return (a + b-1) / b; } constexpr static int ASIZE = 50000; int acount[ASIZE]; constexpr static int SIZE = 1000; int counts[SIZE+1][SIZE+1]; int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) { if (b == 0) { sort(x, x + a); for (int i = 0; i < t; i++) { int index = upper_bound(x, x + a, w[i]) - x; if (index == a) return -1; acount[index]++; } int prefix = 0; int cost = 0; for (int i = a-1; i >= 0; i--) { prefix += acount[i]; cost = max(cost, ceil_div(prefix, a - i)); } return cost; } sort(x, x + a); sort(y, y + b); for (int i = 0; i < t; i++) { int xx = upper_bound(x, x + a, w[i]) - x; int yy = upper_bound(y, y + b, s[i]) - y; if (xx == a && yy == b) return -1; debug(xx, yy); counts[xx][yy]++; } int cost = 0; for (int i = a; i >= 0; i--) { for (int j = b; j >= 0; j--) { if (i == a && j == b) continue; debug(i, j, counts[i][j]); if (i < a) counts[i][j] += counts[i+1][j]; if (j < b) counts[i][j] += counts[i][j+1]; if (i < a && j < b) counts[i][j] -= counts[i+1][j+1]; cost = max(cost, ceil_div(counts[i][j], a + b - i - j)); } } return cost; }
#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...