zoukankan      html  css  js  c++  java
  • [AtCoder][ARC084]Snuke Festival 题解

    Snuke Festival

    时间限制: 1 Sec 内存限制: 128 MB

    题目描述

    The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. 
    He has N parts for each of the three categories. The size of the i-th upper part is Ai, the size of the i-th middle part is Bi, and the size of the i-th lower part is Ci. 
    To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar. 
    How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.

    Constraints 
    1≤N≤105 
    1≤Ai≤109(1≤i≤N) 
    1≤Bi≤109(1≤i≤N) 
    1≤Ci≤109(1≤i≤N) 
    All input values are integers.

    输入

    Input is given from Standard Input in the following format: 

    A1 … AN 
    B1 … BN 
    C1 … CN

    输出

    Print the number of different altars that Ringo can build.

    样例输入


    1 5 
    2 4 
    3 6

    样例输出

    3

    提示

    The following three altars can be built: 
    Upper: 1-st part, Middle: 1-st part, Lower: 1-st part 
    Upper: 1-st part, Middle: 1-st part, Lower: 2-nd part 
    Upper: 1-st part, Middle: 2-nd part, Lower: 2-nd part

    题解

    简单的排序+二分查找,善用STL即可。

    第一次拿到个人训练赛第一好开心嘤嘤嘤

    代码

    #include <iostream>
    #include <algorithm>
    
    using namespace std;
    
    int n, aa[3][100001];
    long long ans = 0;
    
    int main() {
        ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
        cin >> n;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < n; j++) cin >> aa[i][j];
            sort(aa[i], aa[i] + n);
        }
    
        for (int i = 0; i < n; i++) {
            unsigned long j = lower_bound(aa[0], aa[0] + n, aa[1][i]) - aa[0];
            unsigned long k = upper_bound(aa[2], aa[2] + n, aa[1][i]) - aa[2];
            ans += (long long) (n - k) * j;
        }
        cout << ans;
        return 0;
    }
  • 相关阅读:
    DrawerLayout侧滑菜单
    pagerslidingtabstrip 横向滑动
    Android对话框
    关于不同页面的传参分析
    ajax异步传输数据,return返回值为空
    mCustomScrollbar 滚动条的使用
    angular实现表格的全选、单选、部分删除以及全部删除
    iOS风格的弹出框(alert,prompt,confirm)
    下拉刷新,上拉加载功能--dropload.js的使用
    页面水印效果的实现--新篇
  • 原文地址:https://www.cnblogs.com/xfl03/p/9413778.html
Copyright © 2011-2022 走看看