Let's call an array tt dominated by value vv in the next situation. At first, array tt should have at least 22 elements. Now, let's calculate number of occurrences of each number numnum in tt and define it as occ(num)occ(num). Then tt is dominated (b…
Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest(dp+线段树) 题目链接 题意: 给定3个人互不相同的多个数字,可以把数字移动给别人,问最少移动几次后可以使第一个人的数字为1~m1,第二个人m1~m2,第三个人m2~n(可以没有数字) 题解: 设c[1][i]为第一个人m1为i时需要移动的次数,c[3][i]为m2为i是第三个人需要操作的次数,当其他两个人数字合法时,第二个人的数字也会合法.枚举第一个人的每个i,…
题:https://codeforces.com/contest/1257/problem/E 题意:给定3个数组,可行操作:每个数都可以跳到另外俩个数组中去,实行多步操作后使三个数组拼接起来形成升序. 输出最小操作次数 dp: #include<bits/stdc++.h> using namespace std; ; ]; int a[M]; ///dp[i][0]表示前i个数全属于第一个数组所要花费的最小代价 ///dp[i][1]表示前i个数全属于第一.二个数组所要花费的最小代价 //…
传送门 A. Two Rival Students 签到. Code /* * Author: heyuhhh * Created Time: 2019/11/13 22:37:26 */ #include <bits/stdc++.h> #define MP make_pair #define fi first #define se second #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #defi…
E. The Contest A team of three programmers is going to play a contest. The contest consists of…
D. Yet Another Monster Killing Problem You play a computer game. In this game, you lead a party of…
B. Magic Stick Recently Petya walked in the forest and found a magic stick. Since Petya really likes numbers, the first thing he learned was spells for changing numbers. So far, he knows only two spells that can be applied to a positive integer: If t…
题意: 给你n个关卡,每个关卡有一个怪物,怪物的攻击力为a[i],你有n个英雄,每个英雄有一个攻击力,和疲劳值,只要英雄的攻击力比怪物的高就算打过了,同时疲劳减一,一天只能出战一个英雄,一个英雄可以打好几关(只要在疲劳范围内),打不过的话英雄就结束今天的挑战,转到第二天.问最少需要出战多少英雄才能通过所有关卡. 思路:先用一个数组.跑出相同忍耐值时,攻击力越大.然后·跑出这个数组的后缀pre数组,pre数组的含义是:忍耐值一定,攻击力最大.然后通过O(n)的复杂度跑·怪物的数组.当怪物的a[i]…