- 博客(14)
- 收藏
- 关注
原创 B - WeirdSort
You are given an array aa of length n. You are also given a set of distinct positions p1,p2,…,pm, where 1≤pi<n. The position pipi means that you can swap elements a[pi] and a[pi+1]. You can apply t...
2020-02-29 21:09:45 391
原创 A - Add Odd or Subtract Even
You are given two positive integers aa and bb.In one move, you can change aa in the following way: Choose any positive odd integer x(x>0) and replace a with a+x; choose any positive even intege...
2020-02-29 20:08:42 155
原创 A - ConneR and the A.R.C. Markland-N
A.R.C. Markland-N is a tall building with nn floors numbered from 11 to nn. Between each two adjacent floors in the building, there is a staircase connecting them. It’s lunchtime for our sensei Colin ...
2020-02-27 15:15:48 244
原创 dp背包
一、01背包 有N件物品,一个容量为W的背包,第i件物品的重量为w[i],价值为v[i],求将哪些装入背包可使价值最大。 代码 有N种物品,一个容量为V的背包,每种物品都有无限件可用,第i种物品的费用为c[i],价值为v[i],求将哪些物品装入背包可试这些物品的费用总和不超过背包容量。且价值总和最大。 **代码** ...
2020-02-26 18:13:19 107
原创 康康线段树
线段树是一种二叉搜索树,它可以将一个区间划分为一些单元区间,每个单元区间对应线段树中的一个叶节点。 对于线段树中的每一个非叶子节点[a,b],它的左儿子表示的区间为[a,(a+b)/2],右儿子表示的区间为[(a+b)/2+1,b],所以线段树是平衡二叉树,最后的子节点数目为N,即整个线段树区间的长度。 ...
2020-02-25 16:57:25 92
原创 Minimum Inversion Number
The inversion number of a given number sequence a1, a2, …, an is the number of pairs (ai, aj) that satisfy i < j and ai > aj. For a given sequence of numbers a1, a2, …, an, if we move the first ...
2020-02-25 15:26:01 72
原创 Balanced Lineup
For the daily milking, Farmer John’s N cows (1 ≤N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To keep things s...
2020-02-21 17:17:10 88
原创 Just a Hook
In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length. Now Pudge w...
2020-02-20 17:34:40 104
原创 Mezo Playing Zoma
Today, Mezo is playing a game. Zoma, a character in that game, is initially at position x=0x=0. Mezo starts sending nn commands to Zoma. There are two possible commands: ‘L’ (Left) sets the position x...
2020-02-19 21:01:24 120
原创 Just Eat It!
Today, Yasser and Adel are at the shop buying cupcakes. There are nn cupcake types, arranged from 11 to nn on the shelf, and there are infinitely many of each type. The tastiness of a cupcake of type ...
2020-02-19 21:01:11 276
原创 C - A Simple Problem with Integers
You have N integers, A1, A2, … , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the su...
2020-02-19 17:07:11 141
原创 I Hate It
很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input 本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M(0<N<=200000 ,0<M<5000 ),...
2020-02-18 17:22:25 71
原创 敌兵布阵
C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。 中央情报局要研究敌人究竟演习什么战术,所以...
2020-02-17 18:05:38 126
原创 最少拦截系统
某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹.怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截系统. ...
2020-02-16 17:00:25 122
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人