제출 #1017618

#제출 시각아이디문제언어결과실행 시간메모리
1017618n3rm1n휴가 (IOI14_holiday)C++17
0 / 100
30 ms65536 KiB
#include <bits/stdc++.h> #include "holiday.h" using namespace std; const int MAXN = 21, MAXMASK = (1 << 21) + 10; int dp[MAXN][MAXMASK]; long long sum[MAXMASK]; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { //cout << MAXN << " " << MAXMASK << endl; int inf = 1e9; for (int i = 0; i < n; ++ i) { for (int mask = 0; mask <= (1 << (n-1)); ++ mask) { dp[i][mask] = inf; } } for (int mask = 0; mask <= (1 << (n-1)); ++ mask) { for (int v = 0; v < n; ++ v) { if(((1 << v) & mask))sum[mask] += 1LL * attraction[v]; } } dp[start][0] = 0; long long ans = 0; for (int mask = 0; mask <= (1 << (n-1)); ++ mask) { for (int v = 0; v < n; ++ v) { if(dp[v][mask] == inf)continue; for (int add = 0; add < n; ++ add) if(!(mask & (1 << add)))dp[add][(mask | (1 << add))] = min(dp[add][(mask | (1 << add))], dp[v][mask] + abs(v - add) + 1); if(dp[v][mask] <= d)ans = max(ans, sum[mask]); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...