LUXURY7这款产品有哪些特别之处?
- 内容介绍
- 文章标签
- 相关推荐
本文共计591个文字,预计阅读时间需要3分钟。
A. 小马与期望最大时间限制:1000MS,内存限制:262144KB,64位IO格式:%I64d。尝试帮助他解决问题。你被给定一个包含n个顶点和m条边的加权有向图。你需要找到一个路径(可能不是简单路径),使得路径的总权重最大。
A.LittlePonyandExpectedMaximumTimeLimit:1000MSMemoryLimit:262144KB64bitIOFormat:%I64d so try to help him in solving the problem.You are given a weighted directed graph with n vertices and m edges. You need to find a path (perhaps, non-simple) with maximum number of edges, such that the weights of the edges increase along the path. In other words, each edge of the path must have strictly greater weight than the previous edge in the path.
Help Pashmak, print the number of edges in the required path.
Input
The first line contains two integers n, m(2 ≤ n ≤ 3·105; 1 ≤ m ≤ min(n·(n - 1), 3·105)). Then, m lines follows. The i-th line contains three space separated integers: ui, vi, wi(1 ≤ ui, vi ≤ n; 1 ≤ wi ≤ 105) which indicates that there‘s a directed edge with weight wi from vertex ui to vertex vi.
It‘s guaranteed that the graph doesn‘t contain self-loops and multiple edges.
Output
Print a single integer — the answer to the problem.
Sample Input
Input3 31 2 12 3 13 1 1Output1Input3 31 2 12 3 23 1 3Output3Input6 71 2 13 2 52 4 22 5 22 6 95 4 34 3 4Output6Hint
In the first sample the maximum trail can be any of this trails: .
In the second sample the maximum trail is .
In the third sample the maximum trail is .
一到很水的dp,只要知道原理,学过背包的都能做出来。 C - BoredomTime Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d 1 ≤ m ≤ 105). The second line contains space-separated integers a1, a2, ..., an(1 ≤ ai ≤ 109).Output
Print a single integer — the maximum final height of the smallest flower.
Sample Input
Input6 2 32 2 2 2 1 1Output2Input2 5 15 8Output9Hint
In the first sample beaver can water the last 3 flowers at the first day. On the next day he may not to water flowers at all. In the end he will get the following heights: [2, 2, 2, 3, 2, 2]. The smallest flower has height equal to 2. It‘s impossible to get height 3 in this test.
二分,并用pre[l] += 1 , pre[l+w] -= 1 ,来维护区间的变化,使判断的过程用O(n)实现。但用线段树的成段更新也能过。LUXURY 7
本文共计591个文字,预计阅读时间需要3分钟。
A. 小马与期望最大时间限制:1000MS,内存限制:262144KB,64位IO格式:%I64d。尝试帮助他解决问题。你被给定一个包含n个顶点和m条边的加权有向图。你需要找到一个路径(可能不是简单路径),使得路径的总权重最大。
A.LittlePonyandExpectedMaximumTimeLimit:1000MSMemoryLimit:262144KB64bitIOFormat:%I64d so try to help him in solving the problem.You are given a weighted directed graph with n vertices and m edges. You need to find a path (perhaps, non-simple) with maximum number of edges, such that the weights of the edges increase along the path. In other words, each edge of the path must have strictly greater weight than the previous edge in the path.
Help Pashmak, print the number of edges in the required path.
Input
The first line contains two integers n, m(2 ≤ n ≤ 3·105; 1 ≤ m ≤ min(n·(n - 1), 3·105)). Then, m lines follows. The i-th line contains three space separated integers: ui, vi, wi(1 ≤ ui, vi ≤ n; 1 ≤ wi ≤ 105) which indicates that there‘s a directed edge with weight wi from vertex ui to vertex vi.
It‘s guaranteed that the graph doesn‘t contain self-loops and multiple edges.
Output
Print a single integer — the answer to the problem.
Sample Input
Input3 31 2 12 3 13 1 1Output1Input3 31 2 12 3 23 1 3Output3Input6 71 2 13 2 52 4 22 5 22 6 95 4 34 3 4Output6Hint
In the first sample the maximum trail can be any of this trails: .
In the second sample the maximum trail is .
In the third sample the maximum trail is .
一到很水的dp,只要知道原理,学过背包的都能做出来。 C - BoredomTime Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d 1 ≤ m ≤ 105). The second line contains space-separated integers a1, a2, ..., an(1 ≤ ai ≤ 109).Output
Print a single integer — the maximum final height of the smallest flower.
Sample Input
Input6 2 32 2 2 2 1 1Output2Input2 5 15 8Output9Hint
In the first sample beaver can water the last 3 flowers at the first day. On the next day he may not to water flowers at all. In the end he will get the following heights: [2, 2, 2, 3, 2, 2]. The smallest flower has height equal to 2. It‘s impossible to get height 3 in this test.
二分,并用pre[l] += 1 , pre[l+w] -= 1 ,来维护区间的变化,使判断的过程用O(n)实现。但用线段树的成段更新也能过。LUXURY 7

