C. Jury Marks

这个题目虽然是只有1600,但是还是挺思维的。

有点难想。

应该可以比较快的推出的是这个肯定和前缀和有关,

x x+a1 x+a1+a2 x+a1+a2+a3...

x+sum=b

所以我们可以通过b来枚举每一个x,如果这个x可以满足找到m个b,那就说明这个x是合理的。

但是要注意的是,这个sum的去重,为什么要去重呢,因为如果不去虫,就是找到两个相同的  因为x=b-sum

所以可以只要枚举b[1]即可,因为对于每一个b,其中一个确定之后,剩下的b的位置也固定了。

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<iomanip>
#define INF 99999999
using namespace std;
const int maxn = 2e6 + ;
typedef long long ll;
int a[maxn];
ll sum[maxn];
map<ll, int>mp; int main()
{
int n, m;
scanf("%d%d", &n, &m);
for(int i=;i<=n;i++)
{
scanf("%lld", &sum[i]);
sum[i] += sum[i - ];
mp[sum[i]] = ;
}
for (int i = ; i <= m; i++) scanf("%d", &a[i]);
sort(sum + , sum + + n);
int len = unique(sum + , sum + + n) - sum - ;
int ans = ;
for(int i=;i<=len;i++)
{
int cnt = , num = a[] - sum[i];
for(int j=;j<=m;j++)
{
if (mp[a[j] - num]) cnt++;
}
if (cnt >= m) ans++;
}
printf("%d\n", ans);
return ;
}

C. Jury Marks 思维的更多相关文章

  1. C. Jury Marks 思维题

    http://codeforces.com/contest/831/problem/C 做的时候想不到,来了个暴力. 对于每个b[i],枚举每一个a[i],就有1个可能的情况. 然后用vector存起 ...

  2. C. Jury Marks

    C. Jury Marks time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  3. Codeforces831C Jury Marks

    C. Jury Marks time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  4. #424 Div2 Problem C Jury Marks (二分 && 暴力 && std::unique && 思维)

    题目链接 :http://codeforces.com/contest/831/problem/C 题意 :选手有一个初始积分,接下来有k个裁判为他加分或减分(时间顺序给出),然后告诉你n(1< ...

  5. CF831C Jury Marks

    思路: 关键在于“插入”一个得分之后,其他所有得分也随之确定了. 实现: #include <iostream> #include <cstdio> #include < ...

  6. 【Codeforces Round #424 (Div. 2) C】Jury Marks

    [Link]:http://codeforces.com/contest/831/problem/C [Description] 有一个人参加一个比赛; 他一开始有一个初始分数x; 有k个评委要依次对 ...

  7. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)

    http://codeforces.com/contest/831 A. Unimodal Array time limit per test 1 second memory limit per te ...

  8. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) A 水 B stl C stl D 暴力 E 树状数组

    A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  9. CF-831C

    C. Jury Marks time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

随机推荐

  1. Tomorrow - 地形生成(1)

    原理很简单,请不要喷. 效果展示  种子输入框  种子为12345的地形  种子为23456的地形 代码展示 globalvar map random_set_seed(real(get_string ...

  2. Docker-Bridge Network 03 自定义网络

    本节介绍自定义bridge network的自定义网络. 1.前言2.创建自定义网络2.1 创建网络2.2 指定网段创建网络3.创建容器3.1 指定网络创建容器3.2 指定IP创建容器4.通信4.1 ...

  3. [V&N2020 公开赛]TimeTravel 复现

    大佬友链(狗头):https://www.cnblogs.com/p201821440039/ 参考博客: https://www.zhaoj.in/read-6407.html https://cj ...

  4. Python 开发工具链全解

    可能刚开始学习Python时,有人跟你说可以将源文件所在的文件夹添加到 PYTHONPATH环境变量中,然后可以从其他位置导入此代码.在大多数情况下,这个人常常忘记补充这是一个非常糟糕的主意.有些人在 ...

  5. tensorflow1.0 构建神经网络做非线性归回

    """ Please note, this code is only for python 3+. If you are using python 2+, please ...

  6. SK-learn实现k近邻算法【准确率随k值的变化】-------莺尾花种类预测

    代码详解: from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split fr ...

  7. ubuntu下载速度慢的解决办法--修改下载源

    操作:https://blog.csdn.net/qq_24326765/article/details/81916222 推荐源:https://blog.csdn.net/qq_36328643/ ...

  8. (第四篇)Linux命令初识之常用系统管理命令

    1.hostname [命令作用]用于显示和设置系统的主机名称(但是不会永久保存,重启后会恢复) [命令语法]hostname(选项)(参数) [常用选项] -a:显示主机别名(alias name) ...

  9. Qt5 escape spaces in path

    There are two possible ways. You can either use escaped quotes (inserting the string between quotes) ...

  10. qt tableview 选择模式

    QAbstractItemView::SingleSelection QAbstractItemView::ContiguousSelection QAbstractItemView::Extende ...