Codeforces 458B Distributed Join

题目没看懂 数据库什么的。。

照着样例直接贪心居然又AC了。。

#include<bits/stdc++.h>
using namespace std;
long long a[100020],b[100020];
int main()
{
    int m,n;
    scanf("%d%d",&m,&n);
    long long sum1=0,sum2=0,s1=0,s2=0,Max1=0,Max2=0;
    for(int i=1;i<=m;i++)
    {
        scanf("%I64d",&a[i]);
        sum1+=a[i];
        if(a[i]>Max1)
        {
            Max1=a[i];
            s1=i;
        }
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%I64d",&b[i]);
        sum2+=b[i];
        if(b[i]>Max2)
        {
            Max2=b[i];
            s2=i;
        }
    }
    long long ans1=sum1*n,ans2=sum2*m;
    for(int i=1;i<=m;i++)
    {
        if(i!=s1&&a[i]<sum2)
            ans2=ans2-sum2+a[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(i!=s2&&b[i]<sum1)
            ans1=ans1-sum1+b[i];
    }
    if(ans1>ans2)
        printf("%I64d\n",ans2);
    else
        printf("%I64d\n",ans1);
    return 0;
}

Codeforces 458B Distributed Join

时间: 2024-10-27 11:53:43

Codeforces 458B Distributed Join的相关文章

《Distributed Programming With Ruby》读书笔记三 Hello World Rinda and TupleSpace (Part1.2-1)

Chapter2: Rinda Including 7 parts: "Hello World" the Rinda Way Understanding Tuples and TupleSpaces Callbacks and Observers Security with Rinda Renewing Rinda Services Conclusion Endnotes When reviewing all of our DRb applications, you will noti

Codeforces Round #200 (Div. 2) (ABCDE题解)

比赛链接:http://codeforces.com/contest/344 A. Magnets time limit per test:1 second memory limit per test:256 megabytes Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets inst

CodeForces 510B 无向图找环的两种方法(搜索与并查集)

题目连接:http://codeforces.com/problemset/problem/510/B 解法: dfs 每次把父节点的值记录并传递下去,判断一下新达到节点: (1)没有走过 → 继续搜索: (2)走过&&不是父节点(对于本题步数也要>=4) → 找到环: 并查集 每个节点映射成 i*m+j从起点开始分别把它下面与于右面的节点加进来,如果发现有节点已经在集合中,那么环已经找到了. DFS: #include<cstdio> #include<cstdl

[Big Data - ZooKeeper] ZooKeeper: A Distributed Coordination Service for Distributed Applications

ZooKeeper ZooKeeper: A Distributed Coordination Service for Distributed Applications Design Goals Data model and the hierarchical namespace Nodes and ephemeral nodes Conditional updates and watches Guarantees Simple API Implementation Uses Performanc

spark 笔记 2: Resilient Distributed Datasets: A Fault-Tolerant Abstraction for In-Memory Cluster Computing

http://www.cs.berkeley.edu/~matei/papers/2012/nsdi_spark.pdf ucb关于spark的论文,对spark中核心组件RDD最原始.本质的理解,没有比这个更好的资料了.必读. Abstract RDDs provide a restricted form of shared memory, based on coarse grained transformations rather than fine-grained updates to s

使用map端连接结合分布式缓存机制实现Join算法

前面我们介绍了MapReduce中的Join算法,我们提到了可以通过map端连接或reduce端连接实现join算法,在文章中,我们只给出了reduce端连接的例子,下面我们说说使用map端连接结合分布式缓存机制实现Join算法 1.介绍 我们使用频道类型数据集和机顶盒用户数据集,进行连接,统计出每天.每个频道.每分钟的收视人数 2.数据集 频道类型数据集就是channelType.csv文件,如下示例 机顶盒用户数据集来源于“08.统计电视机顶盒中无效用户数据,并以压缩格式输出有效数据”这个实

HDFS分布式文件系统(The Hadoop Distributed File System)

The Hadoop Distributed File System (HDFS) is designed to store very large data sets reliably, and to stream those data sets at high bandwidth to user applications. In a large cluster, thousands of servers both host directly attached storage and execu

CodeForces 344

这次是作为晚训题目做的,代码都挺短,考的是思维,想到了分分钟AC,想不到就依然是想不到-- A - Magnets Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 344A Description Mad scientist Mike entertains himself by arranging rows of domi

Reading Papers about Distributed Replication

A. Practical Byzantine Fault Tolerance 1.What's its checkpoint? We will refer to the states produced by the execution of these requests as checkpoints and we will say that a checkpoint with a proof is a stable checkpoint. When the replication code in