"Solving" task assignments

Source: Internet
Author: User

Use dp[i][j] to indicate the first I task, a complete need J time, B completed need dp[i][j] time.

The recursive equation is also easy to get out

Dp[i][j]=min (Dp[i-1][j]+b[i],dp[i-1][j-a[i])//Where A[i],b[i] respectively indicates the time required for A/b to complete the task I.

Attached code

1#include <algorithm>2#include <iostream>3#include <fstream>4#include <cstdlib>5#include <cstring>6#include <cmath>7 using namespacestd;8Ifstream Fin ("divide.in");9Ofstream Fout ("Divide.out");Ten intdp[203][40005]={0},rws=0, rw[203][2]={0}; One intMainvoid) A { -Fin>>RWS; -   for(intI=1; i<=rws;i++) fin>>rw[i][0]>>rw[i][1]; thedp[0][0]=0; -  intnum=0; -   for(intI=1; i<=rws;i++) -     { +num+=rw[i][0]; -       for(intj=0; j<=num;j++) +         { Adp[i][j]=dp[i-1][j]+rw[i][1]; at          if(j>=rw[i][0]) -            { -Dp[i][j]=min (dp[i][j],dp[i-1][j-rw[i][0]]); -            } -         } -     } in  intans=0x7fffffff; -   for(intI=1; i<=num;i++) to     { +ans=min (Ans,max (dp[rws][i],i)); -     } thefout<<ans; *  return 0; $}

"Solving" task assignments

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.