Tc srm 562 DIV 2

Source: Internet
Author: User

The last question of the Exercise competition has not been answered yet. To be continued
A. FAQ ~ But there was a magical error.
Return "NO ". I actually converted O to 0 ..
[Cpp]
# Include <iostream>
# Include <cstdio>
# Include <algorithm>
# Include <string>
# Include <cmath>
# Include <cstring>
# Include <queue>
# Include <set>
# Include <vector>
# Include <stack>
# Include <map>
# Include <iomanip>
# Define PI acos (-1.0)
# Deprecision Max 2005
# Define inf 1 <28
# Define LL (x) (x <1)
# Define RR (x) (x <1 | 1)
# Define FOR (I, s, t) for (int I = (s); I <= (t); ++ I)
# Define ll long
Using namespace std;
 
Bool cmp (int a, int B)
{
Return a> B;
} Www.2cto.com
Class CucumberMarket {
Public:
String check (vector <int> price, int budget, int k ){
Int num = price. size ();
Int * a = new int [num];
For (int I = 0; I <num; I ++)
A [I] = price [I];
Sort (a, a + num, cmp );
Int sum = 0;
For (int I = 0; I <k & I <num; I ++)
Sum + = a [I];
If (sum> budget)
Return "NO ";
Else
Return "YES ";
 
}
};
B. Simulate the question. Mark each 'B', and then find the next 'B' from here, traverse along the diagonal line ', compare the distance between two, sum + = min (the distance between the two, T), because it is possible that the two 'B' cannot form a straight line, because the number of T is too small, so we need to find the minimum value.
[Cpp]
Int num [100] [100];
Class PastingPaintingDivTwo {
Public:
Long countColors (vector <string> clipboard, int T ){
Memset (num, 0, sizeof (num ));
Int n, m;
For (int I = 0; I <clipboard. size (); I ++)
{
N = clipboard. size ();
For (int j = 0; j <clipboard [I]. length (); j ++)
{
M = clipboard [I]. length ();
If (clipboard [I] [j] = 'B ')
{
Num [I] [j] ++;
}
}
}
Ll sum = 0;
For (int I = 0; I <n; I ++)
{
For (int j = 0; j <m; j ++)
{
Int SPNs = 0;
Int k;
Int spp = 0;
If (num [I] [j])
{
For (k = 0; k <= min (n-I, m-j); k ++)
{
If (num [I + k] [j + k])
{
Spp + = SPNs;
SPNs = k-spp;
Sum + = min (spn, T );
}
Num [I + k] [j + k] = 0;
}
// Sum + = SPNs;
Sum + = T;
}
}
}
Return sum;
}
};

 

Related Article

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.