Submission #529520

#TimeUsernameProblemLanguageResultExecution timeMemory
529520zxcvbnmtrapezoid (balkan11_trapezoid)C++14
8 / 100
52 ms2648 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<array<int, 4>> a(n); for(auto& i : a) { for(auto& j : i) { cin >> j; } } auto cmp = [](const auto& l, const auto& r) { return min(l[1], l[3]) < min(r[1], r[3]); }; auto ok = [&](int i, int j) { return a[j][0] > a[i][1] && a[j][2] > a[i][3]; }; sort(a.begin(), a.end(), cmp); // for(auto& i : a) { // for(auto& j : i) { // cout << j << " "; // } // cout << "\n"; // } // bool can[n][n]; // memset(can, false, sizeof can); // // for(int i = 0; i < n; i++) { // for(int j = i+1; j < n; j++) { // can[i][j] = can[j][i] = ok(i, j); // } // } vector<int> dp(n, 1); vector<int> mx(n, 1); for(int i = 0; i < n; i++) { int l = 0, r = i-1, ans = -1; while(l <= r) { int mid = (l + r) / 2; if (ok(mid, i)) { ans = mid; l = mid + 1; } else { r = mid - 1; } } if (ans == -1) continue; dp[i] = dp[i] + mx[ans]; mx[i] = max(mx[i-1], dp[i]); } cout << mx[n-1] << " " << mx[n-1] << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...