Test instructions: Needs to be repaired from (0,0) point to (x, y)
Where there are n and y axes parallel to the river
Unit cost of road repairing C1 repair Bridge Unit Cost C2
Q What is the minimum total cost?
Idea: Merge all the rivers
The length of the bridge repeatedly
Find the minimum cost
#include <cstdio> #include <iostream> #include <cstring> #include <cmath> #include <stdlib.h > #include <algorithm> #include <queue> #include <stack> #include <ctype.h>using namespace std;const int maxn=100+5;int vis[10000+100];int a[maxn];int cmp (int a,int b) {return a>b;} int max (int a,int b) {if (a>b) return A; else return b;} int main () {int kase; scanf ("%d", &kase); while (kase--) {int n,ans=0,cnt=0,res=0,maxn=0,minn,numa=0,numb=0,sum=0; scanf ("%d", &n); for (int i=0;i<n;i++) {int op,num; scanf ("%d%d", &op,&num); if (op==2) ans+=num; if (op==1) {a[cnt++]=num;sum+=num;} } if (cnt>0) {memset (vis,0,sizeof (VIS)); Vis[0]=1; for (int i=0;i<cnt;i++) {for (int j=10000;j>=a[i];j--) {if (V Is[j-a[i]]==1) Vis[j]=1; } } int hsum= (sum+1)/2; int l=hsum;//r=hsum; while (vis[l]==0) {l--; } maxn=max (L,sum-l); } RES=ANS+MAXN; printf ("%d\n", res); } return 0;}
CSU 1548:design Road (three points)