Home > Back-end >  For help, the problem of c array
For help, the problem of c array

Time:09-26

Time limit: 1000 ms memory limit: 262144 KB
Title description
WWD. There are a lot of calls to make,

WWD phone contacts a total of n, each contact have a phone number si and a digital mi, said WWD called her a few times a day,

Due to the mobile phone is broken WWD, only through input Numbers to call phone number, so the WWD every day to spend a lot of time input digital, WWD came up with a solution, that is a button for mobile phones equipped with k, each button can hit a series of Numbers, but for every phone call, can only use a button, and only in the absence of any digital input can use,

WWD. Want to know, in the optimal situation, she at least a day to input a few Numbers (not use the add button input),

Input format
The first line of two positive integers n and k, contact number and can add the number of buttons,

The next n lines, each line only contains a number of string si, and a positive integer mi,

The output format
A line is the answer,

The sample input 1
3 1
0001
001
01 1
The sample output 1
14
The sample 2 input
3 1
0001
001
01 1
The sample 2 output
18
The data size and agreed
Subject adopt bundling test,

A phone number a total length of L,

Ensure n 1000 or less, L 1000 or less, k 20 or less, mi 1000 or less,

Subtask1 (20 PTS)
N 10 or less, L 100 or less,

Subtask2 (20 PTS)
N 100 or less, L 100 or less,

Subtask3 (20 PTS)
N 500 or less, L 500 or less,

Subtask4 (40 PTS)
No special restrictions,

CodePudding user response:

#include
using namespace std;
Int main ()
{
Short z=getchar (), n, I, v, j, k, b [k], c [1000], a [n] [1001].
The scanf (" % d % d ", & amp; N, & amp; K);
for(i=0; i{
For (z=0; z!=' '; Z++)
{
The scanf (" % d ", & amp; A [I] [z]);
}
The scanf (" % d ", & amp; B [I]);
}
for(i=0; i{
For (j=0; j<=z; J++)
C=b * [I] a [I] [I] [j];

}
for(i=1; ifor(j=i; j<=n; + + j)
If (c [I] {
Int t=c [I];
C=c [j] [I];
C [j]=t;
}
For (I=k; iV=c + v [I];
Printf (" % d ", v);
return 0;
}

CodePudding user response:

O great god and see what's the problem with my code

CodePudding user response:

This code you are I see not bottom go to, you this is a C + + code or the C code, and many of the most basic contents didn't grasp, suggest you don't rush to write complex code, beat basis point class to speak first
  • Related