Submission #973578

#TimeUsernameProblemLanguageResultExecution timeMemory
973578SuPythonyCyberland (APIO23_cyberland)C++17
0 / 100
1648 ms2097152 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; vector<vector<pair<int,double>>> al; double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> a) { al.assign(N,vector<pair<int,double>>()); vector<vector<double>> cost(N,vector<double>(N)); for (int i=0; i<M; i++) { al[x[i]].push_back({y[i],c[i]}); al[y[i]].push_back({x[i],c[i]}); cost[x[i]][y[i]]=c[i]; cost[y[i]][x[i]]=c[i]; } vector<vector<double>> dp(N,vector<double>(K+1,1e18)); for (int i=0; i<=K; i++) dp[0][i]=0; for (int i=1; i<=H; i++) { for (int j=0; j<=K; j++) { if (a[i]==1||j==0) dp[i][j]=dp[i-1][j]+cost[i][i-1]; else if (a[i]==0) dp[i][j]=0; else { dp[i][j]=min((dp[i-1][j-1]+cost[i][i-1])/2,dp[i-1][j]+cost[i][i-1]); } } } double ans=1e18; for (int i=0; i<=K; i++) { ans=min(ans,dp[H][i]); } if (ans==1e18) return -1; 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...