Submission #1069743

#TimeUsernameProblemLanguageResultExecution timeMemory
1069743TheQuantiXRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
65 ms11972 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll INF = 1000000000000000000LL; ll n, m, q, k, x, y, a, b, c; long long plan_roller_coaster(vector<int> s, vector<int> t) { n = (int) s.size(); if (n <= 16) { vector< vector<ll> > dp((1 << n), vector<ll>(n, INF)); ll ans = INF; for (int i = 1; i < (1 << n); i++) { vector<int> v; for (int j = 0; j < n; j++) { if ((i >> j) & 1) { v.push_back(j); } } for (auto j : v) { if (v.size() == 1) { dp[i][j] = 0; } else { for (int k = 0; k < n; k++) { if (!((i >> k) & 1) || j == k) { continue; } dp[i][j] = min(dp[i][j], dp[i - (1 << j)][k] + max(0, t[k] - s[j])); } } if (v.size() == n) { ans = min(ans, dp[i][j]); } // cout << bitset<4>(i) << ' ' << j << ' ' << dp[i][j] << '\n'; } } return ans; } vector< pair<ll, ll> > v; for (int i = 0; i < n; i++) { v.push_back({t[i], s[i]}); } sort(v.begin(), v.end()); sort(s.begin(), s.end()); ll e = 0; for (int i = 0; i < n; i++) { while (e < n && s[e] <= v[i].first) { e++; } if (e - (v[i].second <= v[i].first ? 1 : 0) < i) { return 1; } } return 0; }

Compilation message (stderr)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:34:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   34 |                 if (v.size() == n) {
      |                     ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...