UVA 607 Scheduling Lectures

UVA_607

    我们可以首先预处理出来一节课可以连着上哪些topic,并且这节课的满意度是多少。

    之后用两个数组f[i]、s[i],分别表示一直上到以课程i为结尾的课时的总满意度以及上过的总课时数,动规的过程就像是跳房子,看当前位置可以跳到那个位置,就尝试去更新那个位置。

#include<stdio.h>
#include<string.h>
#define MAXN 1010
#define MAXL 510
#define INF 0x3f3f3f3f
int N, L, C, f[MAXN], t[MAXN], p[MAXN][MAXN], s[MAXN];
int init()
{
int i, j, k, tt, di;
scanf("%d", &N);
if(!N)
return 0;
scanf("%d%d", &L, &C);
for(i = 1; i <= N; i ++)
scanf("%d", &t[i]);
for(i = 1; i <= N; i ++)
for(j = i; j <= N; j ++)
p[i][j] = INF;
for(i = 1; i <= N; i ++)
{
k = 0;
for(j = i; j <= N; j ++)
{
k += t[j];
if(k <= L)
{
tt = L - k;
if(tt == 0)
di = 0;
else if(tt >= 1 && tt <= 10)
di = -C;
else
di = (tt - 10) * (tt - 10);
if(di < p[i][j])
p[i][j] = di;
}
else
break;
}
}
return 1;
}
void solve()
{
int i, j, k;
memset(f, 0x3f, sizeof(f));
memset(s, 0x3f, sizeof(s));
for(i = 1; i <= N; i ++)
if(p[1][i] != INF)
{
s[i] = 1;
f[i] = p[1][i];
}
for(i = 1; i < N; i ++)
if(f[i] != INF)
for(j = i + 1; j <= N; j ++)
{
if(p[i + 1][j] == INF)
break;
if(s[i] + 1 < s[j])
{
s[j] = s[i] + 1;
f[j] = f[i] + p[i + 1][j];
}
else if(s[i] + 1 == s[j] && f[i] + p[i + 1][j] < f[j])
f[j] = f[i] + p[i + 1][j];
}
printf("Minimum number of lectures: %d\n", s[N]);
printf("Total dissatisfaction index: %d\n", f[N]);
}
int main()
{
int x = 0;
while(init())
{
if(x ++)
printf("\n");
printf("Case %d:\n", x);
solve();
}
return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
网络化系统讲义,作者是IEEE控制系统分会的主席。Francesco Bullo is a Professor in the Mechanical Engineering Department at the University of California, Santa Barbara. He received the Laurea degree “summa cum laude” in Electrical Engineering from the University of Padova, Italy, in 1994, and the Ph.D. degree in Control and Dynamical Systems from the California Institute of Technology in 1999. From 1998 to 2004, he was an Assistant Professor with the Coordinated Science Laboratory at the University of Illinois at Urbana-Champaign. Since 2004 he has been at University of California, Santa Barbara; he is currently affiliated with the Department of Electrical and Computer Engineering, the Department of Computer Science, and the Center for Control, Dynamical Systems and Computation. Professor Bullos’ research focuses on modeling, dynamics and control of multi-agent network systems, with applications to robotic coordination, power systems, distributed computing and social networks. Previous work includes contributions to geometric control, Lagrangian systems, vehicle routing, and motion planning. Professor Bullo has published more than 270 papers in international journals, books, and refereed conferences. He is the coauthor, with Andrew D. Lewis, of the book “Geometric Control of Mechanical Systems” (Springer, 2004, 0-387-22195-6), with Jorge Cortés and Sonia Martínez, of the book “Distributed Control of Robotic Networks” (Princeton, 2009, 978-0-691-14195-4), and with Stephen L. Smith of the book “Lectures on Robotics Planning and Kinematics” (SIAM, 2016, under review); his “Lectures on Network Systems” (CreateSpace, 2018, 978-1986425643) is available on his website. Professor Bullo is a Fellow of IEEE and IFAC. He is currently a Distinguished Lecturer of the IEEE Control Systems Society. He received the 2018 Distinguished Scientist Award by the Chinese Academy of Sciences. His articles received the 2008 CSM Outstanding Paper Award from IEEE CSS, the 2011 Hugo Schuck Best Paper Award from AACC, the 2013 SIAG/CST Best Paper Prize from SIAM, the 2014 Automatica Best Paper Prize from IFAC, the 2016 Guillemin-Cauer Best Paper Award from IEEE CAS, and the 2016 TCNS Outstanding Paper Award from IEEE CSS. Professor Bullo served as advisor or co-advisor of 22 graduated PhD students. He received the 2015 UCSB Outstanding Graduate Mentor Award and the 2004 UIUC COE Outstanding Advisor Award. His students’ papers were finalists for the Best Student Paper Award at the IEEE Conference on Decision and Control (2002, 2005, 2007), and the American Control Conference (2005, 2006, 2010). Professor Bullo has served, for the IEEE Control Systems Society, as 2011-2012 Vice-President for Technical Activities, as 2013-2014 Vice-President for Publications, as 2007-2009 Elected Member of the Board of Governors and as Program Chair for the 2016 IEEE Conference in Decision and Control. He will serve as President Elect / President / President Past of the IEEE Control Systems Society during the triennium 2017–2019. Additionally, he served on the Editorial Boards of “IEEE Transactions on Automatic Control,” “ESAIM: Control, Optimization, and the Calculus of Variations,” “SIAM Journal of Control and Optimization,” and “Mathematics of Control, Signals, and Systems”. From July 2013 to June 2017, Professor Bullo served as Mechanical Engineering Department Chair at UCSB. In this role he had responsibilities over academic personnel matters, educational programs, facilities management, governance, finances, and communication/development.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值