当前位置:网站首页>The 16th Heilongjiang Provincial Collegiate Programming Contest
The 16th Heilongjiang Provincial Collegiate Programming Contest
2022-06-30 21:10:00 【WDLieqi】
Catalog
D - Doin’ Time
Topic ideas
It can be used as an exercise interval dp The revised template question of .Title code
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 310;
const int mod = 1000003;
int n;
LL p[N];
LL s[N][N], f[N][N];
int main()
{
cin >> n;
for (int i = 1; i <= n; i ++)
cin >> p[i];
for (int i = 1; i <= n; i ++)
{
LL t = 1;
for (int j = i; j <= n; j ++)
t = (t * p[j]) % mod, s[i][j] = t;
}
for (int len = 2; len <= n; len ++)
{
for (int i = 1; i + len - 1 <= n; i ++)
{
int l = i, r = i + len - 1;
f[l][r] = -1;
for (int k = l; k < r; k ++)
{
f[l][r] = max(f[l][r], f[l][k] + f[k + 1][r] + (s[i][k] - s[k + 1][r]) * (s[i][k] - s[k + 1][r]));
}
}
}
cout << f[1][n] << '\n';
return 0;
}
J - JOJO’s Factory
Topic ideas
Because the title has been given to M The scope of is Less than or equal to 2 * n - 3, So we can conclude that there must be no such thing as
4 6
1 1
1 2
1 3
2 1
2 2
2 3
Data like this , So it can be concluded that as long as it is not A It matches n individual B You must be able to pair them all .
Title code
#include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
const int N = 5e5 + 10;
int ma[N], mb[N], n, m;
void solve()
{
cin >> n >> m;
int a = n, b = n;
while (m -- )
{
int x, y;
cin >> x >> y;
ma[x] ++;
mb[y] ++;
if (ma[x] >= n)
a --;
if (mb[y] >= n)
b --;
}
cout << min(a, b) << '\n';
}
int main()
{
IOS // If you don't, it will time out
int T = 1;
//cin >> T;
while (T--)
{
solve();
}
return 0;
}
K. Keep Eating
Topic ideas
We can put all the weight together first sum, Then eat it once 1 weight , In the end k individual , Just eat it k / 2 That's all right. , Pay attention to the special judgment sum Is it greater than k.
Title code
#include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
void solve()
{
LL n, k;
cin >> n >> k;
LL res1 = 0, res2 = 0;
for (int i = 0; i < n; i ++)
{
int x;
cin >> x;
res1 += x;
}
if (res1 < k)
{
cout << 0 << '\n';
return;
}
res2 += res1 - k + k / 2;
cout << res2 << '\n';
}
int main()
{
IOS int T = 1;
//cin >> T;
while (T--)
{
solve();
}
return 0;
}
边栏推荐
猜你喜欢

Lumiprobe cell biology - dia, instructions for lipophilic tracer

Web APIs 综合案例-Tab栏切换 丨黑马程序员

Lumiprobe nucleic acid quantitative qudye dsDNA br detection kit

Go build server Foundation

Adobe Photoshop (PS) - script development - remove file bloated script

Introduction of 3D Max fine model obj model into ArcGIS pro (II) key points supplement

申请Vector 总线协议彩图壁纸挂画,非常棒哦!

Lumiprobe dye hydrazide - BDP FL hydrazide solution

Binary search tree (1) - concept and C language implementation

Text recognition svtr paper interpretation
随机推荐
凤凰架构——架构师的视角
B_QuRT_User_Guide(34)
C file pointer
Iclr'22 spotlight | how to measure the amount of information in neural network weights?
注册设备监理师难考吗,和监理工程师有什么关系?
B_QuRT_User_Guide(33)
毕业设计
《大厂面试》之JVM篇21问与答
MySQL advanced 3
有趣插件汇总
关于,奇安信检测代码漏洞,XSS系列解决
go搭建服务器基础
Software engineering UML drawing
Markdown笔记简明教程
k个一组反转链表
毕业五年,想当初若没有入行测试,我是否还会如这般焦虑
Personal developed penetration testing tool Satania
MySQL简介、详细安装步骤及使用 | 黑马程序员
变异系数法matlab代码[通俗易懂]
uniapp-路由uni-simple-router