摘要:
双向链表直接模拟。用一个辅助数组maxSum来维护一下前k项中[1,k]的最大和。因为光标是一格一格的移动,所以每次光标右移的时候动态更新一下即可。时间复杂度O(n)。#include #include #include #include using namespace std;const int MAXN = 1000100;const int INF = 1 pre = NULL; head->next = NULL; node *cur = head; maxSum[0] = -INF; sum[0] = 0; int... 阅读全文
posted @ 2013-09-07 21:58
冰鸮
阅读(301)
评论(0)
推荐(0)
摘要:
起点和终点各做一次单源最短路, d1[i], d2[i]分别代表起点到i点的最短路和终点到i点的最短路,枚举商业线车票cost(a, b); ans = min( d1[a] + cost(a, b) + d2[b] );#include #include #include #include #include #include using namespace std;const int MAXN = 1010;const int INF = 1 rhs.d; }};struct Edge{ int from, to, dist; Edge() { } Edge( i... 阅读全文
posted @ 2013-09-07 16:45
冰鸮
阅读(211)
评论(0)
推荐(0)

浙公网安备 33010602011771号