Submission #955742

#TimeUsernameProblemLanguageResultExecution timeMemory
955742vjudge1Pinball (JOI14_pinball)C++17
11 / 100
42 ms8536 KiB
#include <bits/stdc++.h> #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() //#define int long long using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; const int mod = 1e9 + 7; const int LOG = 20; const int maxn = 1e5 + 5; const double eps = 1e-9; ll dp[2][505][505]; int32_t main() { int n, m; cin >> n >> m; vector<array<int, 4> > v(n+2); set<int> s; s.insert(1); s.insert(m); for(int i=1; i<=n; i++) { cin >> v[i][0] >> v[i][1] >> v[i][2] >> v[i][3]; s.insert(v[i][0]); s.insert(v[i][1]); s.insert(v[i][2]); } vector<int> comp(all(s)); for(int i=1; i<=n; i++) { v[i][0] = lower_bound(all(comp), v[i][0]) - comp.begin(); v[i][1] = lower_bound(all(comp), v[i][1]) - comp.begin(); v[i][2] = lower_bound(all(comp), v[i][2]) - comp.begin(); } for(int i=0; i<comp.size(); i++) for(int j=i; j<comp.size(); j++) dp[0][i][j] = dp[1][i][j] = 1e16; for(int i=0; i<comp.size(); i++) dp[0][i][i] = 0; for(int i=n+1; i>=2; i--) { for(int j=0; j<comp.size(); j++) { for(int k=j; k<comp.size(); k++) { if(dp[0][j][k] >= 1e16) continue; dp[1][j][k] = min(dp[1][j][k], dp[0][j][k]); if(j <= v[i-1][2] && v[i-1][2] <= k) { int l = min(j, v[i-1][0]); int r = max(k, v[i-1][1]); dp[1][l][r] = min(dp[1][l][r], dp[0][j][k] + v[i-1][3]); } } } swap(dp[0], dp[1]); } if(dp[0][0][comp.size()-1] >= 1e16) cout << -1 << '\n'; else cout << dp[0][0][comp.size()-1] << '\n'; return 0; }

Compilation message (stderr)

pinball.cpp: In function 'int32_t main()':
pinball.cpp:45:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i=0; i<comp.size(); i++)
      |                  ~^~~~~~~~~~~~
pinball.cpp:46:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         for(int j=i; j<comp.size(); j++) dp[0][i][j] = dp[1][i][j] = 1e16;
      |                      ~^~~~~~~~~~~~
pinball.cpp:47:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for(int i=0; i<comp.size(); i++) dp[0][i][i] = 0;
      |                  ~^~~~~~~~~~~~
pinball.cpp:50:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for(int j=0; j<comp.size(); j++) {
      |                      ~^~~~~~~~~~~~
pinball.cpp:51:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |             for(int k=j; k<comp.size(); k++) {
      |                          ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...