제출 #134768

#제출 시각아이디문제언어결과실행 시간메모리
134768Mahdi_JfriRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
134 ms10748 KiB
#include "railroad.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define bit(a , b) (((a)>>(b))&1) const int maxn = 2e5 + 20; const int maxm = (1 << 16) + 20; int ind[maxn] , s[maxn] , t[maxn] , n; ll dp[maxm][20]; ll solve() { memset(dp , 63 , sizeof dp); int hlp = (1 << n) , mn = 0; for(int mask = 1; mask < hlp; mask++) for(int i = 0; i < n; i++) if(bit(mask , i)) { if(mask == (1 << i)) { dp[mask][i] = 0; break; } for(int j = 0; j < n; j++) if(bit(mask ^ (1 << i) , j)) dp[mask][i] = min(dp[mask][i] , dp[mask ^ (1 << i)][j] + max(0 , t[j] - s[i])); } ll ans = *min_element(dp[hlp - 1] , dp[hlp - 1] + n); return ans; } bool cmp(int x , int y) { return t[x] < t[y]; } long long plan_roller_coaster(vector<int> S, vector<int> T) { n = (int)S.size(); for(int i = 0; i < n; i++) s[i] = S[i] , t[i] = T[i] , ind[i] = i; if(n <= 17) return solve(); sort(ind , ind + n); for(int i = 0; i < n; i++) s[i] = S[ind[i]] , t[i] = T[ind[i]]; sort(S.begin() , S.end()); int mn = 0; for(int i = 0; i < n; i++) { int x = upper_bound(S.begin() , S.end() , t[i]) - S.begin(); if(s[i] >= t[i]) { int k = upper_bound(t , t + n , s[i]) - t; mn = min(mn , x - 1 - (n - k + 1)); if(k > i + 1) mn = min(mn , x - (n - i)); } else mn = min(mn , x - (n - i)); } if(mn < -1) return 1; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

railroad.cpp: In function 'long long int solve()':
railroad.cpp:20:23: warning: unused variable 'mn' [-Wunused-variable]
  int hlp = (1 << n) , mn = 0;
                       ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...