Codeforces Round #322 (Div. 2)

Source: Internet
Author: User
Tags bitset cmath

Water A-vasya The Hipster

/************************************************* author:running_time* Created time:2015/9/28 Monday 16:58:13* Fil E name:a.cpp ************************************************/#include <cstdio> #include <algorithm># Include <iostream> #include <sstream> #include <cstring> #include <cmath> #include <string > #include <vector> #include <queue> #include <deque> #include <stack> #include <list># Include <map> #include <set> #include <bitset> #include <cstdlib> #include <ctime>using namespace std; #define Lson L, Mid, RT << 1#define Rson mid + 1, R, RT << 1 | 1typedef long ll;const int N = 1e5 + 10;const int INF = 0x3f3f3f3f;const int MOD = 1e9 + 7;const Double EPS = 1e-8;in  T Main (void) {int A, b;scanf ("%d%d", &a, &b); int ans = min (A, b);p rintf ("%d", ans); A-= ans, b-= Ans;ans =    A/2 + b/2;printf ("%d\n", ans); return 0;}

Water b-luxurious Houses

From back to front, maintain a suffix maximum value

/************************************************* author:running_time* Created time:2015/9/28 Monday 16:58:21* Fil E name:b.cpp ************************************************/#include <cstdio> #include <algorithm># Include <iostream> #include <sstream> #include <cstring> #include <cmath> #include <string > #include <vector> #include <queue> #include <deque> #include <stack> #include <list># Include <map> #include <set> #include <bitset> #include <cstdlib> #include <ctime>using namespace std; #define Lson L, Mid, RT << 1#define Rson mid + 1, R, RT << 1 | 1typedef long ll;const int N = 1e5 + 10;const int INF = 0x3f3f3f3f;const int MOD = 1e9 + 7;const Double EPS = 1e-8;in T a[n], Mx[n], ans[n];int main (void) {int n;scanf ("%d", &n), for (int i=1; i<=n; ++i) {scanf ("%d", &a[i]);} Mx[n] = A[n];ans[n] = 0;for (int i=n-1; i>=1;-I.) {if (A[i] <= mx[i+1]) {Ans[i] =MX[I+1] + 1-a[i];} Mx[i] = max (mx[i+1], a[i]);} for (int i=1; i<=n; ++i) {printf ("%d%c", ans[i], i = = n?    ' \ n ': ');} return 0;}

  

Greedy c-developing Skills

Test instructions: The number of n can be increased by up to K, each limit is 100, ask Max sum (A[i]/10)

Analysis: If k is very small, priority is given to the need for the smallest number to the next ten integers, sorted by this rule. If there is any surplus then continue, at this time each number plus 10, until 100 or k<=0, timely break.

/************************************************* author:running_time* Created time:2015/9/28 Monday 16:58:28* Fil E name:c.cpp ************************************************/#include <cstdio> #include <algorithm># Include <iostream> #include <sstream> #include <cstring> #include <cmath> #include <string > #include <vector> #include <queue> #include <deque> #include <stack> #include <list># Include <map> #include <set> #include <bitset> #include <cstdlib> #include <ctime>using namespace std; #define Lson L, Mid, RT << 1#define Rson mid + 1, R, RT << 1 | 1typedef long ll;const int N = 1e5 + 10;const int INF = 0x3f3f3f3f;const int MOD = 1e9 + 7;const Double EPS = 1e-8;in    T a[n];int cal (int x) {if (x = =) return 0;    int a = X/10; Return (A + 1) * 10-X;} BOOL CMP (int x, int y) {return cal (X) < cal (y);} int main (void) {int n, k;scanf ("%d%d", &n, &k); for (int i=1; i<=n; ++i) {scanf ("%d", &a[i]);} Sort (a+1, a+1+n, CMP), while (K > 0) {bool up = false;for (int i=1; i<=n; ++i) {if (a[i] = =) Continue;int dt = cal (A[i]); if (dt > k | | k <= 0) break;if (dt <= k) {k-= dt;a[i] + = Dt;up = True;}} if (!up) break;} int ans = 0;for (int i=1; i<=n; ++i) {ans + = a[i]/10;}    printf ("%d\n", ans); return 0;}

  

Analog D-three Logos

Test instructions: Well understood, that is, three rectangles together into a square

Analysis: Think of very simple, nothing is two situations, the game did not think so much, the code is very frustrated, suggest to look at the picture on the line ...

/************************************************* author:running_time* Created time:2015/9/28 Monday 17:39:02* Fil E Name:D. cpp ************************************************/#include <cstdio> #include <algorithm># Include <iostream> #include <sstream> #include <cstring> #include <cmath> #include <string > #include <vector> #include <queue> #include <deque> #include <stack> #include <list># Include <map> #include <set> #include <bitset> #include <cstdlib> #include <ctime>using namespace std; #define Lson L, Mid, RT << 1#define Rson mid + 1, R, RT << 1 | 1typedef long ll;const int N = 1e5 + 10;const int INF = 0x3f3f3f3f;const int MOD = 1e9 + 7;const Double EPS = 1e-8;in T Main (void) {int x[3], y[3];for (int i=0; i<3; ++i) {scanf ("%d%d", &x[i], &y[i]), if (X[i] > Y[i]) swap (x [i], y[i]);} int SX = X[0] + x[1] + x[2];if (SX = = Y[0] && SX = = Y[1] &&  SX = = Y[2]) {//First case printf ("%d\n", SX), for (int i=0; i<3; ++i) {for (Int. j=1; j<=x[i]; ++j) {for (int k=1; k<=y[i]; ++k) {printf ("%c", i = = 0?) ' A ': (i = = 1)? ' B ': ' C ');} Puts ("");}}        else{//the second case of bool flag = False;int N = 0, id = 0;for (int i=0; i<3; ++i) {if (n < y[i]) {n = Y[i];id = i;}}        int tx = N-x[id];                for (int i=0, i<3; ++i) {for (int j=0; j<3; ++j) {if (i = = id | | j = = ID) continue;                if (x[i] = = X[j] && x[i] = = tx) {if (Y[i] + y[j] = = N) {flag = True;break;}                } else if (x[i] = = Y[j] && x[i] = = tx) {if (Y[i] + x[j] = = N) {flag = True;break;}                } else if (y[i] = = X[j] && y[i] = = tx) {if (X[i] + y[j] = = N) {flag = True;break;}                } else if (y[i] = = Y[j] && y[i] = = tx) {if (X[i] + x[j] = = N) {flag = True;break;} }}}if (flag) {//Output answer printf ("%d\n", N), for (int i=1; i<=x[id]; ++i) {for (int j=1; j<=y[id]; ++J) {printf ("%c", id = = 0?) ' A ': (id = = 1)? ' B ': ' C ');} Puts ("");} Char p, q;if (id = = 0) p = ' B ', q = ' C ', else if (id = = 1) p = ' a ', q = ' C '; elsep = ' a ', q = ' B '; for (int i=0; i<3; ++i) {f                or (int j=0; j<3; ++j) {if (i = = id | | j = = ID) continue; if (x[i] = = X[j] && x[i] = tx) {if (Y[i] + y[j] = = N) {for (Int. k=1; k<=tx; ++k) {for (int l=1; l<=n; ++l) {pri NTF ("%c", L <= y[i]? p:q);} Puts ("");}                return 0;} } else if (x[i] = = Y[j] && x[i] = tx) {if (Y[i] + x[j] = = N) {for (int k=1; k<=tx; ++k) {for (int l=1; l<=n; ++l) {printf ("%c", L <= y[i]? p:q);} Puts ("");}                return 0;} } else if (y[i] = = X[j] && y[i] = tx) {if (X[i] + y[j] = = N) {for (int k=1; k<=tx; ++k) {for (int l=1; l<=n; ++l) {printf ("%c", L <= x[i]? p:q);} Puts ("");}                return 0;} } else if (y[i] = = Y[j] && y[i] = = tx) {if (X[i] + x[j] = = N) {for (int k=1; k<=tx; + +)k) {for (int l=1; l<=n; ++l) {printf ("%c", L <= x[i]? p:q);} Puts ("");}                return 0;}    }}}}elseputs ("1");} return 0;}

 

Finally, the last couple night observation of the stars, predicting this rating will exceed 1700, in order to be able to continue to div2 in the food, "deliberately" hack failure.

Codeforces Round #322 (Div. 2)

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.