传送门

•题意

给k个数列,从中k个数列中找出任意2个数列 i ,j

使得数列i删除第x个数,和数列j删除第y个数的和相等

若存在,输出 i ,x 和 j,y

•思路

每个数列之间的联系为数列的和之间的差det

如果开二维数组记录每个数列之间的det的话,显然是不可行的_(:з」∠)_

这里用map<x ,pair<i ,j > >mp表示序列 i 删除第 j 个数后的总和为 x;

如果某两个序列各删除一个数,得到的总和相等,

也就是后一个序列得到的总和已存在(被前一个所记录)的话,就找到了

•代码

 #include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+;
map<int,pair<int,int> > mp;
int a[maxn];
ll sum;
int main()
{
int k;
cin>>k;
for(int i=;i<=k;i++)
{
int n;
cin>>n;
sum=;
for(int j=;j<=n;j++)
{
cin>>a[j];
sum+=a[j];
}
for(int j=;j<=n;j++)
{
int x=sum-a[j];
if(mp.count(x)&&mp[x].first!=i)
{
cout<<"YES"<<endl;
cout<<i<<' '<<j<<endl;
cout<<mp[x].first<<' '<<mp[x].second<<endl;
return ;
}
mp[x]=make_pair(i,j);
}
}
cout<<"NO"<<endl;
}

Codeforces Round #486 (Div. 3) C "Equal Sums" (map+pair<>)的更多相关文章

  1. Codeforces Round #486 (Div. 3)-C. Equal Sums

    C. Equal Sums time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  2. Codeforces Round #198 (Div. 2) C. Tourist Problem (数学+dp)

    C. Tourist Problem time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  3. Codeforces Round #511 (Div. 2)-C - Enlarge GCD (素数筛)

    传送门:http://codeforces.com/contest/1047/problem/C 题意: 给定n个数,问最少要去掉几个数,使得剩下的数gcd 大于原来n个数的gcd值. 思路: 自己一 ...

  4. Codeforces Round #238 (Div. 2) D. Toy Sum(想法题)

     传送门 Description Little Chris is very keen on his toy blocks. His teacher, however, wants Chris to s ...

  5. Codeforces Round #376 (Div. 2)F. Video Cards(前缀和)

    题目链接:http://codeforces.com/contest/731/problem/F 题意:有n个数,从里面选出来一个作为第一个,然后剩下的数要满足是这个数的倍数,如果不是,只能减小为他的 ...

  6. Codeforces Round #256 (Div. 2) D. Multiplication Table(二进制搜索)

    转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmod ...

  7. Codeforces Round #363 (Div. 2) B. One Bomb (水题)

    B. One Bomb time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  8. Codeforces Round #479 (Div. 3) F. Consecutive Subsequence (简单dp)

    题目:https://codeforces.com/problemset/problem/977/F 题意:一个序列,求最长单调递增子序列,但是有一个要求是中间差值都是1 思路:dp,O(n)复杂度, ...

  9. Codeforces Round #256 (Div. 2) C. Painting Fence(分治贪心)

    题目链接:http://codeforces.com/problemset/problem/448/C C. Painting Fence time limit per test 1 second m ...

随机推荐

  1. SYN1621型 定位定向授时设备

    SYN1621型 定位定向授时设备 定位定向授时设备使用说明视频链接: http://www.syn029.com/h-pd-274-0_310_39_-1.html 请将此链接复制到浏览器打开观看 ...

  2. python下SQLAlchemy的使用

    SQLAlchemy是python中orm常用的框架.支持各种主流的数据库,如SQLite.MySQL.Postgres.Oracle.MS-SQL.SQLServer 和 Firebird. 在安装 ...

  3. 【设计模式】行为型08状态模式(status Pattern)

    状态模式(status Pattern)       定义:允许一个对象在其内部状态改变时改变它的行为,对象看起来似乎修改了它的类.其别名为状态对象(Objects for States).与命令模式 ...

  4. valet环境PHPstorm+xdebug调试

    1.安装xdebug 2.配置xdebug zend_extension="/usr/local/Cellar/php@7.2/7.2.18/pecl/20170718/xdebug.so& ...

  5. php抽奖概率程序

    抽奖概率思想: 1.给每一个奖项设置要给概率数,如下面所有奖品综合设置为100,iphone5s是5,也就是5% 2.然后通过php生成随机数函数生成一个在总概率之间的随机数 如:抽第一个奖品5s的时 ...

  6. redis在asp.net 中的应用

    1.redis介绍 Nosql数据库作为关系型数据库的补充,在互联网公司已经得到广泛的运用.redis便是其中的代表之一,redis是一种(key,value)基于内存的数据库,并支持多种数据结构,如 ...

  7. 【HDU - 2181】哈密顿绕行世界问题(dfs+回溯)

    -->哈密顿绕行世界问题 Descriptions: 一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市.  Input 前2 ...

  8. Python连载21-collections模块

    一.collections模块 1.函数namedtuple (1)作用:tuple类型,是一个可命名的tuple (2)格式:collections(列表名称,列表) (3)​返回值:一个含有列表的 ...

  9. 02(b)多元无约束优化问题-最速下降法

    此部分内容接02(a)多元无约束优化问题的内容! 第一类:最速下降法(Steepest descent method) \[f({{\mathbf{x}}_{k}}+\mathbf{\delta }) ...

  10. MYSQL5.7---ONLY_FULL_GROUP_BY 异常处理

    异常介绍: ONLY_FULL_GROUP_BY 指的是你查询的语句使用到了group by 例如  select name,age from person group by sex; 此时你grou ...