To The Moon is a independent game released in November 2011, it is a role-playing adventure game powered by RPG Maker.
The premise of To The Moon is based around a technology that allows us to permanently reconstruct the memory on dying man. In this problem, we’ll give you a chance, to implement the logic behind the scene.
You‘ve been given N integers A[1],A[2],...,A[N]. On these integers, you need to implement the following operations:
Clrd: Adding a constant d for every {Ai∣l≤i≤r}, and increase the time stamp by 1, this is the only operation that will cause the time stamp increase.
Qlr: Querying the current sum of {Ai∣l≤i≤r}.
Hlrt: Querying a history sum of {Ai∣l≤i≤r} in time t.
Bt: Back to time t. And once you decide return to a past, you can never be access to a forward edition anymore.
N,M≤105, ∣A[i]∣≤109, 1≤l≤r≤N, ∣d∣≤104. The system start from time 0, and the first modification is in time 1, t≥0, and won’t introduce you to a future state.
Input
1 2 3
n m A1 A2 ... An ... (here following the m operations. )
Posted onSymbols count in article: 1.4kReading time ≈5 mins.
PRoblem
最优贸易
题目描述
C 国有 n 个大城市和 m 条道路,每条道路连接这 n 个城市中的某两个城市。任意两个城市之间最多只有一条道路直接相连。这 m 条道路中有一部分为单向通行的道路,一部分为双向通行的道路,双向通行的道路在统计条数时也计为 1 条。C 国幅员辽阔,各地的资源分布情况各不相同,这就导致了同一种商品在不同城市的价格不一定相同。但是,同一种商品在同一个城市的买入价和卖出价始终是相同的。
商人阿龙来到 C 国旅游。当他得知同一种商品在不同城市的价格可能会不同这一信息之后,便决定在旅游的同时,利用商品在不同城市中的差价赚回一点旅费。设 C 国 n 个城市的标号从 1∼n,阿龙决定从 1 号城市出发,并最终在 n 号城市结束自己的旅行。在旅游的过程中,任何城市可以重复经过多次,但不要求经过所有 n 个城市。阿龙通过这样的贸易方式赚取旅费:他会选择一个经过的城市买入他最喜欢的商品――水晶球,并在之后经过的另一个城市卖出这个水晶球,用赚取的差价当做旅费。由于阿龙主要是来 C 国旅游,他决定这个贸易只进行最多一次,当然,在赚不到差价的情况下他就无需进行贸易。
现在给出 n 个城市的水晶球价格,m 条道路的信息(每条道路所连接的两个城市的编号以及该条道路的通行情况)。请你告诉阿龙,他最多能赚取多少旅费。
输入输出格式
输入格式:
第一行包含 2 个正整数 n 和 m,中间用一个空格隔开,分别表示城市的数目和道路的数目。
第二行 n 个正整数,每两个整数之间用一个空格隔开,按标号顺序分别表示这 n 个城市的商品价格。
接下来 m 行,每行有 3 个正整数,x,y,z,每两个整数之间用一个空格隔开。如果 z=1,表示这条道路是城市 x 到城市 y 之间的单向道路;如果 z=2,表示这条道路为城市 x 和城市 y 之间的双向道路。
输出格式:
输出文件 trade.out 共 1 行,包含 1 个整数,表示最多能赚取的旅费。如果没有进行贸易,则输出 0。
Posted onSymbols count in article: 872Reading time ≈3 mins.
Problem
Shopping Offers
Description
In a shop each kind of product has a price. For example, the price of a flower is 2 ICU (Informatics Currency Units) and the price of a vase is 5 ICU. In order to attract more customers, the shop introduces some special offers.
A special offer consists of one or more product items for a reduced price. Examples: three flowers for 5 ICU instead of 6, or two vases together with one flower for 10 ICU instead of 12.
Write a program that calculates the price a customer has to pay for certain items, making optimal use of the special offers. That is, the price should be as low as possible. You are not allowed to add items, even if that would lower the price.
For the prices and offers given above, the (lowest) price for three flowers and two vases is 14 ICU: two vases and one flower for the reduced price of 10 ICU and two flowers for the regular price of 4 ICU.
Input
Your program is to read from standard input. The first line contains the number b of different kinds of products in the basket (0≤b≤5). Each of the next b lines contains three values c, k, and p. The value c is the (unique) product code (1≤c≤999). The value k indicates how many items of this product are in the basket (1≤k≤5). The value p is the regular price per item (1≤p≤999). Notice that all together at most 5×5=25 items can be in the basket. The b+2nd line contains the number s of special offers (0≤s≤99). Each of the next s lines describes one offer by giving its structure and its reduced price. The first number n on such a line is the number of different kinds of products that are part of the offer (1≤n≤5). The next n pairs of numbers (c,k) indicate that k items (1≤k≤5) with product code c(1≤c≤999) are involved in the offer. The last number p on the line stands for the reduced price (1≤p≤9999). The reduced price of an offer is less than the sum of the regular prices.
Output
Your program is to write to standard output. Output one line with the lowest possible price to be paid.