码迷,mamicode.com
首页 > 其他好文 > 详细

[Codeforces 519B] A and B and Compilation Errors

时间:2018-09-27 19:46:01      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:pil   error   bit   max   set   mes   ble   div   printf   

[题目链接]

         https://codeforces.com/problemset/problem/519/B

[算法]

         将三个序列分别排序,然后对比元素即可

         时间复杂度 : O(NlogN)

[代码]

        

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;

int n,ans;
int a[MAXN],b[MAXN],c[MAXN];

template <typename T> inline void read(T &x)
{
    T f = 1; x = 0;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) if (c == -) f = -f;
    for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - 0;
    x *= f;
}

int main()
{
        
        int n;
        read(n);
        for (int i = 1; i <= n; i++) read(a[i]);
        for (int i = 1; i <= n - 1; i++) read(b[i]);
        for (int i = 1; i <= n - 2; i++) read(c[i]);
        sort(a + 1,a + n + 1);
        sort(b + 1,b + (n - 1) + 1);
        sort(c + 1,c + (n - 2) + 1);
        int ans = -1;
        for (int i = 1; i <= n - 1; i++)
        {
                if (a[i] == b[i]) continue;
                ans = a[i];
                break;        
        }
        if (ans == -1) ans = a[n];
        printf("%d\n",ans);
        ans = -1;
        for (int i = 1; i <= n - 2; i++)
        {
                if (b[i] == c[i]) continue;
                ans = b[i];
                break;        
        }
        if (ans == -1) ans = b[n - 1];
        printf("%d\n",ans);
        
        return 0;
    
}

 

[Codeforces 519B] A and B and Compilation Errors

标签:pil   error   bit   max   set   mes   ble   div   printf   

原文地址:https://www.cnblogs.com/evenbao/p/9715058.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!