Home > Back-end >  M - FatMouse 's Speed went wrong but can't find the problem
M - FatMouse 's Speed went wrong but can't find the problem

Time:12-05

Title:
FatMouse believes that the fatter a mouse is, the faster - it runs. To disprove this, you want To take the data on a collection of mice and put as large a subset of this data as possible into a sequence so that the weights are increasing, but the speeds are decreasing.
Input
Input contains data for a bunch of mice, one mouse per line, terminated by the end of the file.

The data for a particular mouse will consist of a pair of integers: The first representing its size in grams and The second representing its speed in centimeters per second. Both integers are between 1 and 10000. The data in each test case will contain information for The at most 1000 mice.

Two mice may have the same weight, the same speed, or even the same weight and speed.
The Output
Your program should output a sequence of lines of data; The first line should contain a number n; The remaining n lines should each contain a single positive integer (each one representing a mouse). If these n integers are m [1], [2],... , m [n] then it must be the case that

W [1] [m]
And

S [1] [m] & gt; S [2] [m] & gt; .> S [m] [n]

In order for the answer to be correct, n should be as large as possible.
All inequalities are strict: weights must be strictly increasing, and speeds must be strictly decreasing. There may be many correct outputs for a given input, your program only needs to find one.
My code
#include
#include
#include
#include
#include
#include
# include
# include
# include
# pragma warning (4996) disable:
using namespace std;
Class A
{
Public:
Long long w;
Long long s;
};
Int main ()
{
Long long n, k;
The static A shu [10050];
The static long long dp [10050] [2].
Long long op=1;
While (the scanf (" % LLD % LLD, & amp; Shu (op) w., & amp; Shu (op). S)!=(EOF)
{
Op++;
}
Long long yu=1;
Dp [1] [0]=1; Dp [1] [1]=0;
For (long long I=2; I & lt; The op. I++)
{
Long long maxx=0;
Long long mark=0;
For (long long j=1; J & lt; i; J++)
{
If (shu [j]. J w & lt; Shu [I] w& & Shu [j]. J s & gt; Shu [I] s)
{
Maxx=Max (maxx, dp [j] [0]).
Mark=j;
}
}
If (mark==0)
{
Dp [I] [0]=1;
Dp [I] [1]=0;
}
The else
{
Dp [I] [0]=maxx + 1;
Dp [I] [1]=mark;
}
Yu=Max (yu, dp [I] [0]).
}
Cout & lt; The static long long STR [10050].
Long long jk=1;
For (long long I=(op - 1); I & gt;=1; I -)
{
If (dp [I] [0]==yu)
{
STR [jk]=I; Jk++;
While (1)
{
If (I==0)
{
break;
}
STR [jk]=dp [I] [1]; Jk++;
I=dp [I] [1];
}
}
}
For (long long I=(jk - 2); I & gt;=1; I -)
{
Cout & lt; }
}
Can't find the problem, your input is no problem to try, is there a big help to solve it
  • Related