South Mail eighth session of the Program Design Competition Network Qualifiers summary One (wrong title set)

Source: Internet
Author: User

The birthday present of the handsome God sister paper time limit (normal/java): 1000ms/3000ms running memory limit: 65536KByte

Contest description

A association Daniel Handsome God's sister paper recently again birthday, but sister paper Heart already have a want gift, sister paper want gift is 10 kinds of rare diamonds, handsome God in order to meet the requirements of sister paper, around to know the diamond in a mysterious place, this place has many gods, all the gods stand in a row, Every God has a diamond in his hand, but the lazy handsome god in order to walk less, think of as little as possible to visit the neighboring God, from their hands to obtain diamonds, the number of known sister paper for each diamond demand, ask the handsome God need to visit how many consecutive gods to obtain the sister paper needs diamonds.

Input

This is titled multiple samples, the first line input an integer t (T <= 100), indicating the number of samples, for each group of samples,

The first act consists of a string of 0-9 digits (less than 100,000 in length), representing the gods standing in a row, each of which represents the number of diamonds that God possesses

The second act, 10 numbers, indicates the number of 0-9 diamonds required by sister paper.

Output

Each set of samples outputs a number that indicates the minimum number of consecutive gods that can satisfy a sister's paper needs, and if not, the output "Let's break Up".

Sample input

2
1234567890
0 0 0 1 1 0 1 0 0 0
1234567890
2 0 0 0 0 0 0 0 0 0

Sample output

4
Let's break up

Title Analysis: A typical two-point method, with St and Ed to maintain a period of time, first find the first paragraph to meet the conditions, and then narrow the scope of judgment, not satisfied with the further expansion of the range

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace Std;
int const MAX = 100005;
int const INF = 0X3FFFFFFF;
int need[15], has[15];
Char S[max];

BOOL Judge ()
{
for (int i = 0; i <; i++)
if (Has[i] < need[i])
return false;
return true;
}

int main ()
{
int T;
scanf ("%d", &t);
while (T--)
{
memset (has, 0, sizeof (have));
scanf ("%s", s);
int len = strlen (s);
for (int i = 0; i <; i++)
scanf ("%d", &need[i]);
int st = 0, ed = 0, ans = INF;
while (Ed < Len)
{
while (!judge () && Ed < Len)
{
Has[s[ed]-' 0 '] + +;
Ed + +;
}
while (judge () && St < ed)
{
ans = min (ans, ed-st);
HAS[S[ST]-' 0 ']--;
St + +;
}
}
if (ans = = INF)
printf ("Let's Break Up\n");
Else
printf ("%d\n", ans);
}
}

Xiao Ming's line

time limit (normal/java):2000ms/6000ms Run memory limit: 65536KBYT E

Contest description

TC is a local tyrants, often to the entire training team hair apple, and like to make a team of people in accordance with the number of apples to do some strange things, such as let everyone figure out his right side of the number of apples less than the number of people. Take other people's hand long, everybody to TC of strange hobby also can only adaptation.

Input

Input first behavior a T (T <= 6) represents the number of data groups, each set of data contains an integer n (n person, 1<=n<=100000), and n integers (positive integers, which represent each person corresponding to the number of apples)

Output

For each set of data output n integers, the i-integer represents the number of people on the right side of the I-person Apple less than his.

Sample input

1
4 5 2) 6 1

Sample output

2 1 1 0

Tips

Input please use scanf, output please use printf

There are also spaces after the last digit of the output data

Topic Analysis: Typical reverse order number problem, merge sort and tree array can do

#include <cstdio>
#include <cstring>
int const MAX = 1e5 + 5;
int const INF = 0x7FFFFFFF;
int n, A[max], Res[max];

struct DATA
{
int Val, idx;
}d[max], A1[max], A2[max];

void Merge_sort (int l, int mid, int r, DATA *d)
{
int len1 = mid-l;
int len2 = R-mid;
for (int i = 0; i < len1; i++)
A1[i] = d[i + L];
A1[len1].val = INF;
for (int i = 0; i < len2; i++)
A2[i] = D[i + mid];
A2[len2].val = INF;
int i = 0, j = 0, k = l, tmp = 0;
while (I < len1 | | J < LEN2)
{
if (A1[i].val <= a2[j].val)
{
RES[A1[I].IDX] + = tmp;
D[k + +] = a1[i + +];
}
Else
{
if (a1[i].val! = INF)
TMP + +;
D[k + +] = a2[j + +];
}
}
}

void Merge (int l, int r, DATA *d)
{
if (L = = r-1)
Return
int mid = (L + r) >> 1;
Merge (L, Mid, D);
Merge (Mid, R, D);
Merge_sort (L, Mid, R, D);
}

int main ()
{
int T;
scanf ("%d", &t);
while (T--)
{
memset (res, 0, sizeof (RES));
scanf ("%d", &n);
for (int i = 0; i < n; i++)
scanf ("%d", &a[i]);
for (int i = 0; i < n; i++)
{
D[i].val = A[i];
D[i].idx = i;
}
Merge (0, N, D);
for (int i = 0; i < n; i++)
printf ("%d", res[i]);
printf ("\ n");
}
}

Money time limit (normal/java): 1000ms/3000ms running memory limit: 32768KByte

Contest description

Local Tyrants BJ Current body has cash X yuan, in order to help his poor Diao base friend TC, he said to TC you can now exchange my current cash of any two adjacent numbers up to K times, more out of money to you, TC want to know how much cash you can get.

Input

Enter first behavior an integer t represents the number of data groups, and each group of data has only one row consisting of two digits X and K, with no leading zeros in the numbers

(1 <= T <=, 1 <= x <= 1019, 0 <= k <= 100)

Output

For each set of data, output a number indicating the maximum amount of cash the TC can receive.

Sample input

3
1399 3
256 1
109009 4

Sample output

7920
270
801891

Title analysis: Try to make high-level digital, from the highest bit start to low, first find the maximum number of k steps, if the maximum number of k steps is not the current position of the number, then the maximum number of exchanges so far, and then subtract the initial value can be, because there is no negative numbers, direct i64u

#include <cstdio>
#include <cstring>
#include <algorithm>
#define ULL unsigned long long
using namespace Std;
Char s[20];
int k;

int main ()
{
int T;
scanf ("%d", &t);
while (T--)
{
scanf ("%s%d", S, &k);
Ull Bj_cash, Tc_cash;
SSCANF (S, "%i64u", &bj_cash);
int len = strlen (s), now;
for (int i = 0; i < len; i++)
{
now = i;
for (int j = i + 1; J <= i + K && J < Len; j + +)
if (S[j] > S[now])
now = j;
if (now! = i)
{
for (int j = Now; j > i; j--)
{
Swap (S[j], s[j-1]);
K--;
}
}
}
SSCANF (S, "%i64u", &tc_cash);
printf ("%i64u\n", Tc_cash-bj_cash);
}
}

South Mail eighth session of the Program Design Competition Network Qualifiers summary One (wrong title set)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.