aboutsummaryrefslogtreecommitdiff
path: root/cses
diff options
context:
space:
mode:
Diffstat (limited to 'cses')
-rwxr-xr-xcses/DynamicProgramming/BookShop/mainbin0 -> 17544 bytes
-rwxr-xr-xcses/DynamicProgramming/BookShop/main.cpp89
-rw-r--r--cses/DynamicProgramming/BookShop/main_input0.txt3
-rw-r--r--cses/DynamicProgramming/BookShop/main_output0.txt1
-rwxr-xr-xcses/SortingAndSearching/Apartments/mainbin63000 -> 17200 bytes
-rwxr-xr-xcses/SortingAndSearching/Apartments/main.cpp18
6 files changed, 94 insertions, 17 deletions
diff --git a/cses/DynamicProgramming/BookShop/main b/cses/DynamicProgramming/BookShop/main
new file mode 100755
index 0000000..ba80a62
--- /dev/null
+++ b/cses/DynamicProgramming/BookShop/main
Binary files differ
diff --git a/cses/DynamicProgramming/BookShop/main.cpp b/cses/DynamicProgramming/BookShop/main.cpp
new file mode 100755
index 0000000..7590c13
--- /dev/null
+++ b/cses/DynamicProgramming/BookShop/main.cpp
@@ -0,0 +1,89 @@
+#include<bits/stdc++.h>
+using namespace std;
+
+using ll = long long;
+using pi = pair<int, int>;
+using vpi = vector<pi>;
+using vi = vector<int>;
+using vll = vector<long long>;
+using mpii = map<int, int>;
+using mpll = map<ll, ll>;
+using db = long double;
+
+#define pb push_back
+#define all(x) (x).begin(), (x).end()
+#define rall(x) (x).rbegin(), (x).rend()
+#define lb lower_bound
+#define ub upper_bound
+
+const int MOD = (int)1e9 + 7;
+const db PI = acos((db)-1);
+const int dx[4]{1, 0, -1, 0};
+const int dy[4]{0, 1, 0, -1};
+
+//pretty printing
+template<typename K, typename V>
+void printm(const map<K, V> &mp) {
+ cerr << "{" << endl;
+ for (auto p : mp) {
+ cerr << " { " << p.first << " : " << p.second << " }\n";
+ }
+ cerr << "}" << endl;
+}
+template<typename T>
+void printv(const vector<T> &v) {
+ cerr << "[";
+ for (int i = 0; i < v.size(); i++) {
+ if (i == v.size() - 1) {
+ cerr << v[i];
+ } else {
+ cerr << v[i] << ", ";
+ }
+ }
+ cerr << "]\n";
+}
+
+template<typename T>
+void printvv(const vector<vector<T>> &v) {
+ cerr << "[\n";
+ for (auto &vec : v) {
+ cout << " ";
+ printv(vec);
+ }
+ cerr << "]\n";
+}
+void print() {
+ cerr << "\n";
+}
+
+template<typename T, typename... TS>
+void print(T val, TS... vals) {
+ cerr << val << " ";
+ print(vals...);
+}
+
+
+/* stuff you should look for:
+ ---------------------------
+ * special cases (n=1?)
+ * int overflow, array bounds
+ * do smth instead of nothing and stay organized
+ * WRITE STUFF DOWN
+ * DON'T GET STUCK ON ONE APPROACH
+ */
+
+void solve() {
+
+}
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--) {
+ solve();
+ }
+}
+
+
diff --git a/cses/DynamicProgramming/BookShop/main_input0.txt b/cses/DynamicProgramming/BookShop/main_input0.txt
new file mode 100644
index 0000000..db9738d
--- /dev/null
+++ b/cses/DynamicProgramming/BookShop/main_input0.txt
@@ -0,0 +1,3 @@
+4 10
+4 8 5 3
+5 12 8 1
diff --git a/cses/DynamicProgramming/BookShop/main_output0.txt b/cses/DynamicProgramming/BookShop/main_output0.txt
new file mode 100644
index 0000000..b1bd38b
--- /dev/null
+++ b/cses/DynamicProgramming/BookShop/main_output0.txt
@@ -0,0 +1 @@
+13
diff --git a/cses/SortingAndSearching/Apartments/main b/cses/SortingAndSearching/Apartments/main
index 946f3f6..82bae9d 100755
--- a/cses/SortingAndSearching/Apartments/main
+++ b/cses/SortingAndSearching/Apartments/main
Binary files differ
diff --git a/cses/SortingAndSearching/Apartments/main.cpp b/cses/SortingAndSearching/Apartments/main.cpp
index 676f338..33c3914 100755
--- a/cses/SortingAndSearching/Apartments/main.cpp
+++ b/cses/SortingAndSearching/Apartments/main.cpp
@@ -10,22 +10,6 @@ int main () {
cin.tie(NULL);
int n, m, k;
cin >> n >> m >> k;
- set<int> taken;
- vector<int> v(n);
- vector<int> a(m);
- for (auto &x : v) cin >> x;
- for (auto &x : a) cin >> x;
- sort(all(a));
- int ans = 0;
- for (int i = 0; i < n; i++) {
- auto upper = *upper_bound(all(a), v[i]);
- auto lower = *lower_bound(all(a), v[i]);
- cerr << upper << " " << lower << "\n";
- if(!taken.count(i) && (upper <= v[i] + k || lower >= v[i] - k)) {
- taken.insert(i);
- ans++;
- }
- }
- cout << ans << '\n';
+
}