# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
830894 | 2023-08-19T12:39:50 Z | tolbi | Rarest Insects (IOI22_insects) | C++17 | 5 ms | 312 KB |
#include <bits/stdc++.h> using namespace std; mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count()); #include "insects.h" int min_cardinality(int n) { function<int(int)> f; map<int,int> cev; set<int> olan; for (int i = 0; i < n; ++i) { olan.insert(i); } vector<int> kullandim; vector<int> kullanmadim; f = [&](int x)->int{ if (cev.count(x)) return cev[x]; int ans = 0; vector<int> crr; for (auto it : olan){ crr.push_back(it); move_inside(it); if (press_button()>x){ ans++; crr.pop_back(); kullanmadim.push_back(it); move_outside(it); } else kullandim.push_back(it); } for (int i = 0; i < crr.size(); ++i) { move_outside(crr[i]); } return cev[x]=ans; }; int diff = n-f(1); if (diff==1) return n; int l = 1, r = n/diff; int hueh = 0; while (l<r){ int mid = l+(r-l+1)/2; int hayda = f(mid); if (hayda+hueh>n-(mid*diff)){ r=mid-1; for (auto &it : kullanmadim){ olan.erase(it); } } else { l = mid; hueh+=hayda; for (auto &it : kullandim){ olan.erase(it); } } kullandim.clear(); kullanmadim.clear(); } return l; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 0 ms | 208 KB | Output is correct |
4 | Correct | 0 ms | 208 KB | Output is correct |
5 | Correct | 0 ms | 208 KB | Output is correct |
6 | Correct | 2 ms | 208 KB | Output is correct |
7 | Correct | 2 ms | 208 KB | Output is correct |
8 | Incorrect | 5 ms | 312 KB | Wrong answer. |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 0 ms | 208 KB | Output is correct |
4 | Correct | 0 ms | 208 KB | Output is correct |
5 | Correct | 0 ms | 208 KB | Output is correct |
6 | Correct | 2 ms | 208 KB | Output is correct |
7 | Correct | 2 ms | 208 KB | Output is correct |
8 | Incorrect | 5 ms | 312 KB | Wrong answer. |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 0 ms | 208 KB | Output is correct |
4 | Correct | 0 ms | 208 KB | Output is correct |
5 | Correct | 0 ms | 208 KB | Output is correct |
6 | Incorrect | 0 ms | 208 KB | Wrong answer. |
7 | Halted | 0 ms | 0 KB | - |