There are N points numbered 1 through N on a two-dimensional plane. Point i(1≤i≤N) has coordinates (Xi,Yi). Here, it is guaranteed that X and Y are each permutations of (1,2,…,N).
Find the number of values of i such that the interior (not including the boundary) of the rectangle with sides parallel to the x-axis and y-axis, with lower-left vertex (0,0) and upper-right vertex (Xi,Yi), contains none of the N points numbered 1 through N.
A piece is placed on a two-dimensional plane. Initially, the piece is at coordinate (0,0).
You can perform the following operation zero or more times:
Let the current coordinate of the piece be (x,y). Move the piece to one of the coordinates (x−1,y),(x+1,y),(x,y−1),(x,y+1).
The cost of the k-th operation (k≥1) depends on the parity of k, as follows:
If k is odd: Let the current coordinate of the piece be (x,y). The cost of moving to (x−1,y) or (x+1,y) is A, and the cost of moving to (x,y−1) or (x,y+1) is B.
If k is even: Let the current coordinate of the piece be (x,y). The cost of moving to (x−1,y) or (x+1,y) is B, and the cost of moving to (x,y−1) or (x,y+1) is A.
Find the minimum total cost required to move the piece to coordinate (X,Y).
voidsol() { int A,B,X,Y; cin>>A>>B>>X>>Y; X=abs(X); Y=abs(Y); if(A>B) { A=min(3*B,A); int Z=min(X,Y);//move to (Z,Z) int cost=2*Z*B; int r=max(X,Y)-Z; cost+=(r/2)*(A+B); if(r%2) { if(X==Z) { cost+=B; } else { cost+=A; } } cout<<cost<<endl; } else { B=min(3*A,B); int Z=min(X,Y);//move to (Z,Z) int cost=2*Z*A; int r=max(X,Y)-Z; cost+=(r/2)*(A+B); if(r%2) { if(X==Z) { cost+=B; } else { cost+=A; } } cout<<cost<<endl; } }
补题
D
Problem Statement
A murder occurred at a certain mansion. There are N suspects, called person 1, person 2, …, person N.
Person i entered the mansion at time Si, left the mansion at time Ti, and did not enter or leave at any other times.
The following facts are known about the crime:
There are exactly two culprits.
The crime started at some integer time x, took D units of time, and was completed at time x+D.
Both culprits were in the mansion at all times from the start to the completion of the crime. (They may have entered the mansion exactly when the crime started, or left exactly when it was completed.)
Assuming that both culprits are among the N suspects, how many combinations of the two culprits and the crime start time are possible? Here, the order of the two culprits does not matter.