当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

PHP require/include differences

Double solid histogram / double y-axis

ArcGIS construction and release of simple road network data service and rest call test

stacking集成模型预测回归问题

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

报错:Internal error XFS_WANT_CORRUPTED_GOTO at line 1635 of file fs/xfs/libxfs/xfs_alloc.c.
![翻转链表II[翻转链表3种方式+dummyHead/头插法/尾插法]](/img/a8/6472e2051a295f5e42a88d64199517.png)
翻转链表II[翻转链表3种方式+dummyHead/头插法/尾插法]

银行集体下架的智能投顾产品,为何成了“鸡肋”?

Go语学习笔记 - gorm使用 - 数据库配置、表新增 | Web框架Gin(七)

DM8:生成DM AWR报告
随机推荐
Lumiprobe细胞生物学丨DiA,亲脂性示踪剂说明书
凤凰架构——架构师的视角
What bank card do you need to open an account online? In addition, is it safe to open an account online now?
Double solid histogram / double y-axis
Peking University ACM problems 1004:financial management
coredns 修改upstream
go搭建服务器基础
Vite2兼容低版本chrome(如搜狗80),通过polyfills处理部分需求高版本的语法
B_QuRT_User_Guide(32)
Go语学习笔记 - gorm使用 - 数据库配置、表新增 | Web框架Gin(七)
Adobe-Photoshop(PS)-脚本开发-去除文件臃肿脚本
网络营销之四大误解
Lumiprobe 聚乙二醇化和 PEG 接头丨碘-PEG3-酸研究
centos——开启/关闭oracle
Et la dégradation du modèle de génération de texte? Simctg vous donne la réponse
SQL必需掌握的100个重要知识点:创建和操纵表
Study on lumiprobe modified triphosphate biotin-11-utp
文本生成模型退化怎麼辦?SimCTG 告訴你答案
Gartner聚焦中国低代码发展 UniPro如何践行“差异化”
开发技术-获取10分钟前的时间