Codeforces Round #281 (Div. 2) c

/**
 * @brief Codeforces Round #281 (Div. 2) c
 * @file c.cpp
 * @author 面码
 * @created 2014/12/05 11:54
 * @edited  2014/12/05 11:54
 * @type  brute
 *
 */
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <stack>
#include <vector>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

#define max(a, b)  ((a) > (b) ? (a) : (b))
#define min(a, b)  ((a) > (b) ? (b) : (a)) 
#define abs(a)     ((a) >  0  ? (a) : (0 - (a)))
#define CLR(vec)   memset(vec, 0, sizeof(vec))

#define MAXN 200010
#define MAXV 200000000

typedef long long int ll;

int n_vec[MAXN], m_vec[MAXN];
int tmp, m, n;
ll max_val, max_tmp, max_a, max_b, max_n, max_m;

#ifdef DEBUG
ifstream in;
ofstream out;
#define CIN in
#define COUT out
#else
#define CIN cin
#define COUT cout
#endif

int main(void){
    ios_base::sync_with_stdio(0);
#ifdef DEBUG
    CIN.open("./in",  ios::in);
    COUT.open("./out",  ios::out);
#endif
    CIN >> n;
    for(int i = 0; i < n; ++i)  CIN >> n_vec[i];
    CIN >> m;
    for(int i = 0; i < m; ++i)  CIN >> m_vec[i];

    sort(n_vec, n_vec + n);
    sort(m_vec, m_vec + m);
    
    max_a = 2*n;
    max_b = 2*m;
    max_val = max_a - max_b;

    for(int i = 0, j = 0; i < m; ++i){
        if(i > 0 && n_vec[i] == n_vec[i - 1])   continue;
        while(j < m && m_vec[j] < n_vec[i])     ++j;
        max_n = 2*1LL*i + 3*1LL*(n - i);
        max_m = 2*1LL*j + 3*1LL*(m - j);
        max_tmp = max_n - max_m;
        if( max_tmp > max_val || max_tmp == max_val && max_n > max_a){
            max_a = max_n;
            max_b = max_m;
            max_val = max_tmp;
        }
    }
    COUT << max_a << ":" << max_b << "\n";
    return 0;
}
时间: 2024-10-07 16:16:19

Codeforces Round #281 (Div. 2) c的相关文章

Codeforces Round #281 (Div. 2) a

/**  * @brief Codeforces Round #281 (Div. 2) a  * @file a.cpp  * @author 面码  * @created 2014/12/04 17:49  * @edited  2014/12/04 17:58  * @type  implementation  *  */ #include <iostream> #include <fstream> #include <cstdlib> #include <

Codeforces Round #281 (Div. 2) b

/**  * @brief Codeforces Round #281 (Div. 2) b  * @file b.cpp  * @author 面码  * @created 2014/12/04 18:40  * @edited  2014/12/04 18:40  * @type  implementation  *  */ #include <iostream> #include <fstream> #include <cstdlib> #include <

Codeforces Round #281 (Div. 2) d

/**  * @brief Codeforces Round #281 (Div. 2) d  * @file d.cpp  * @author 闈㈢爜  * @created 2014/12/05 18:19  * @edited  2014/12/05 18:19  * @type  game  *  */ #include <iostream> #include <fstream> #include <cstdlib> #include <stack>

Codeforces Round #281 (Div. 2) A. Vasya and Football 暴力

A. Vasya and Football Vasya has started watching football games. He has learned that for some fouls the players receive yellow cards, and for some fouls they receive red cards. A player who receives the second yellow card automatically receives a red

Codeforces Round #281 (Div. 2) C. Vasya and Basketball 排序

C. Vasya and Basketball Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each successful throw has value of either 2 or 3 points. A throw is worth 2 points if the distance it was made from does

Codeforces Round #281 (Div. 2) B. Vasya and Wrestling 水题

B. Vasya and Wrestling Vasya has become interested in wrestling. In wrestling wrestlers use techniques for which they are awarded points by judges. The wrestler who gets the most points wins. When the numbers of points of both wrestlers are equal, th

Codeforces Round #281 (Div. 2) D. Vasya and Chess 博弈

D. Vasya and Chess Vasya decided to learn to play chess. Classic chess doesn't seem interesting to him, so he plays his own sort of chess. The queen is the piece that captures all squares on its vertical, horizontal and diagonal lines. If the cell is

Codeforces Round #281 (Div. 2) 解题报告 A.B.C.D.

A - Vasya and Football 纯模拟..比较坑的是会有不符合足球常识的地方.. 代码如下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #include <math.h> #include <ctype.h> #include <queue> #inc

Codeforces Round #281 (Div. 2) A. Vasya and Football(模拟)

简单题,却犯了两个错误导致WA了多次. 第一是程序容错性不好,没有考虑到输入数据中可能给实际已经罚下场的人再来牌,这种情况在system测试数据里是有的... 二是chronologically这个词没注意,其实如果输入是按时间顺序的,就直接在线处理就行了,用不着int team1[110][110],team2[110][110]两个数组. #include<iostream> #include<cstdio> #include<cstdlib> #include&l