• Codeforces Round #364 (Div. 2) Cards


    Cards

    题意:

    给你n个牌,n是偶数,要你把这些牌分给n/2个人,并且让每个人的牌加起来相等。

    题解:

    这题我做的时候,最先想到的是模拟,之后码了一会,发现有些麻烦,就想别的方法。之后发现只要把它给的数排序就好了,排完序后输出原来的位置就好,因为每2个都能配对所以最小肯定配最大,第二小配第二大…… 之后就可以a了

    代码:

    #include <bits/stdc++.h>
    using namespace std;
    
    const int INF=0x3f3f3f3f;
    typedef long long ll;
    #define PU puts("")
    #define PI(A) printf("%d
    ",A)
    #define SI(N) scanf("%d",&(N))
    #define SII(N,M) scanf("%d%d",&(N),&(M))
    #define cle(a,val) memset(a,(val),sizeof(a))
    #define rep(i,b) for(int i=0;i<(b);i++)
    #define Rep(i,a,b) for(int i=(a);i<=(b);i++)
    #define reRep(i,a,b) for(int i=(a);i>=(b);i--)
    const double EPS= 1e-9 ;
    
    /*  /////////////////////////     C o d i n g  S p a c e     /////////////////////////  */
    
    const int MAXN= 100 + 9 ;
    
    struct NODE
    {
        int a,b;
        bool operator <(const NODE n) const
        {
            return n.a<a;
        }
    };
    NODE a[MAXN];
    int N;
    
    int main()
    {
        while(~SI(N))
        {
            Rep(i,1,N)
            {
                SI(a[i].a);
                a[i].b=i;
            }
            sort(a+1,a+N+1);
            for (int i=1;i<=N/2;i++)
            {
                printf("%d %d
    ",a[i].b,a[N-i+1].b);
            }
        }
        return 0;
    }
  • 相关阅读:
    1. Change the emulator screen size
    Dynamic Programming for TSP
    框架的概念及用反射技术开发框架的原理
    【PHP 】 伪静态
    【PHP 】伪静态
    框架-Java:Spring MVC
    开源-解决方案-实时数据追踪:Zipkin 介绍
    报表-类型:瀑布图
    报表:目录
    软件-开发软件-Java-Eclipse:百科
  • 原文地址:https://www.cnblogs.com/s1124yy/p/5698555.html
Copyright © 2020-2023  润新知