考场上只做出来四道,第二天一早就写出来了E,蛮绝望的。

A Finding Sasuke

水构造

#include <cstdio>
#include <algorithm>
typedef long long ll;
int T,n;
int a[110]; template <typename T>
inline void read(T &x){
x = 0; char ch = getchar(); int f = 1;
for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
x *= f;
}
int main(){
read(T);
while(T--){
read(n);
for(int i = 1;i <= n; i++) read(a[i]);
for(int i = 2;i <= n; i += 2)
printf("%d %d ",-a[i],a[i - 1]);
printf("\n");
}
return 0;
}

B A New Technique

#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
typedef long long ll;
const int M = 510;
int T,n,m;
int a[M][M]; template <typename T>
inline void read(T &x){
x = 0; char ch = getchar(); int f = 1;
for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
x *= f;
}
std::map <int,int> mp;
int main(){
read(T);
while(T--){
mp.clear();
read(n); read(m);
for(int i = 1;i <= n; i++)
for(int j = 1;j <= m; j++){
read(a[i][j]);
if(j == 1) mp[a[i][j]] = i;
}
for(int i = 1,tmp;i <= m; i++)
for(int j = 1;j <= n; j++){
read(tmp);
if(mp[tmp] != 0){
for(int k = 1;k <= m; k++)
printf("%d ",a[mp[tmp]][k]);
printf("\n");
}
}
}
return 0;
}

C Perform Easily

思维题

#include <cstdio>
#include <algorithm>
#include <vector>
const int M = 100010, inf = 0x3f3f3f3f;
int a[7], n;
int b[M];
int ans = inf;
int maxx; std::vector<std::pair<int, std::pair<int, int> > > v;
template <typename T>
inline void read(T &x){
x = 0; char ch = getchar(); int f = 1;
for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
x *= f;
}
inline bool cmp(int x,int y){
return x > y;
}
int main(){
for(int i = 1;i <= 6; i++) read(a[i]);
read(n);
for(int i = 1;i <= n; i++) read(b[i]);
std::sort(a + 1,a + 1 + 6,cmp);
for(int i = 1;i <= n; i++){
for(int j = 1; j <= 6; j++) v.push_back(std::make_pair(b[i] - a[j],std::make_pair(i, j)));
maxx = std::max(maxx,b[i] - a[1]);
}
std::sort(v.begin(),v.end());
bool flag;
for(int i = 0,l,r;i < int(v.size()); ){
l = i; r = i;
while(r < int(v.size()) - 1 && v[r + 1].first == v[r].first) r++;
flag = 0;
ans = std::min(ans,maxx - v[i].first);
for(int j = l; j <= r; j++){
if(v[j].second.second == 6){
flag = 1; break;
}
maxx = std::max(maxx,b[v[j].second.first] - a[v[j].second.second + 1]);
}
if(flag) break;
i = r + 1;
}
printf("%d\n",ans);
return 0;
}

D Shurikens

大模拟

#include <cstdio>
#include <algorithm>
const int M = 1e5 + 19;
int n; namespace tr{
int tr[M];
void update(int x, int k){
for(; x <= n; x += x & -x)
tr[x] = std::max(tr[x], k);
}
int query(int x){
int res = 0;
for(; x; x -= x & -x)
res = std::max(res, tr[x]);
return res;
}
}//树状数组
int b[M], f[M];
int find(int node){
return node == f[node] ? node : f[node] = find(f[node]);
}
template <typename T>
inline void read(T &x){
x = 0; char ch = getchar(); int f = 1;
for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
x *= f;
}
int cnt = 0, x;
int main(){
read(n);
for(int i = 1; i <= n + 1; ++i) f[i] = i;
for(int i = 1; i <= 2 * n; ++i){
char ch = getchar();
while(ch != '+' && ch != '-') ch = getchar();
if(ch == '+') ++cnt;
else{
read(x);
int pos = find(tr::query(n - x + 1) + 1);
if(pos <= cnt) b[pos] = x, tr::update(n - x + 1, cnt), f[find(pos)] = find(pos + 1);
else return printf("NO\n"), 0;
}
}
printf("YES\n");
for(int i = 1; i <= n; i++) printf("%d ", b[i]);
return 0;
}

E Solo mid Oracle

有一个显而易见的结论: 造成a伤害之后,如果怪回了超过a的血量,那么这次就算白打了。

因此只需要在回满血之前尽可能地输出,就一定是最优的。

具体见代码。

#include <cstdio>
#include <algorithm>
typedef long long ll;
int T,a,b,c,d; template <typename T>
inline void read(T &x){
x = 0; char ch = getchar(); int f = 1;
for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
x *= f;
}
int main(){
read(T);
while(T--){
read(a); read(b); read(c); read(d);
if(a > 1ll * b * c){
printf("-1\n"); continue;
}
if(d >= c){
printf("%d\n",a); continue;
}
int k = a / (1ll * b * d);
printf("%lld\n",(1ll * a * (k + 1) - 1ll * k * (k + 1) * b * d / 2));
}
return 0;
}

Codeforces Round #679 (Div. 2, based on Technocup 2021 Elimination Round 1)的更多相关文章

  1. Codeforces Round #692 (Div. 2, based on Technocup 2021 Elimination Round 3) C. Peaceful Rooks (思维,dsu找环)

    题意:一个棋盘上有一些"车",现在要让这些"车"跑到左倾斜的对角线上,每次可以移动一个棋子,但是棋盘的任意时刻都不能出现一个"车"能吃另一个 ...

  2. Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2) D. XOR-gun (二进制,异或,前缀和)

    题意:给你一组非递减的数,你可以对两个连续的数进行异或,使其合并为一个数,问最少操作多少次使得这组数不满足非递减. 题解:首先,给出的这组数是非递减的,我们考虑二进制,对于三个连续的非递减的最高位相同 ...

  3. Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2) C. Bouncing Ball (后缀和,枚举)

    题意:有一长度为\(n\)的平台,平台有的位置有木桩,可以使小球弹起来,小球必须从第\(p\)个位置开始,而且每次都会向右弹\(k\)个单位,然后有的位置是没有木桩的,你可以在这些的空的位置放一个木桩 ...

  4. Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2) B. Repainting Street (枚举)

    题意:有\(n\)栋房子,每栋房子都有自己的颜色\(c_i\),你每次可以对连续的长度为\(k\)的区间改变任何房子的颜色,问最少多少次可以使得所有房子颜色相同. 题解:因为只有\(100\)中颜色, ...

  5. Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2) A. Prison Break

    题意:有一张\(n\)x\(m\)的图,图中每个点都关押着罪犯,在坐标\((r,c)\)处有一个出口,每名罪犯每秒可以可以像上下最有移动一个单位或者不动,问所有罪犯能够逃离监狱的最少时间. 题解:直接 ...

  6. Codeforces Round #692 (Div. 2, based on Technocup 2021 Elimination Round 3)

    A.In-game Chat 题目:就是从后面数连着的'('的个数是不是严格比剩下的字符多 思路:水题,直接从后往前遍历即可 代码: #include<iostream> #include ...

  7. Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2)

    A. Prison Break 题意:就是在一个n*m的矩阵中,以(1,1)为起点(n,m)为终点,每个点以每个单位1s的速度移动,问总共至少需要多少秒,所有的矩阵点就能够全部移动到(r,c)中 思路 ...

  8. Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2)

    Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2) #include <bits/stdc++ ...

  9. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2)

    A - Forgetting Things 题意:给 \(a,b\) 两个数字的开头数字(1~9),求使得等式 \(a=b-1\) 成立的一组 \(a,b\) ,无解输出-1. 题解:很显然只有 \( ...

随机推荐

  1. 微服务实战系列(五)-注册中心Eureka与nacos区别

    1. 场景描述 nacos最近用的比较多,介绍下nacos及部署吧,刚看了下以前写过类似的,不过没写如何部署及与eureka区别,只展示了效果,补补吧. 2.解决方案 2.1 nacos与eureka ...

  2. linux系统内存爆满的快速解决办法!

    首先用free工具检查一下内存的使用情况: $ free -m total used free shared buff/cache available Mem: 15884 207 573 145 1 ...

  3. Go-简介

    Go简介 Google开发,新的具有面向接口.函数式编程.并发编程特点的编译性强类型通用编程语言 Go核心 1. 接口 2. 并发编程 3. 函数 Go-接口 package main import ...

  4. 操作系统:x86下内存分页机制 (1)

    前置知识: 分段的概念(当然手写过肯定是坠吼的 为什么要分页 当我们写程序的时候,总是倾向于把一个完整的程序分成最基本的数据段,代码段,栈段.并且普通的分段机制就是在进程所属的LDT中把每一个段给标识 ...

  5. React学习小记--setState的同步与异步

    react中,state不能直接修改,而是需要使用setState()来对state进行修改,那什么时候是同步而什么时候是异步呢? 基础代码: setCounter = (v) => { thi ...

  6. Spring循环依赖的问题

      什么是循环依赖?就是两个Bean相互引用,比如用@Autowire 相互注入.   那么Spring是如何解决这个问题的呢?在Bean还未完全实例化前(类只实例化了一部分),将bean提前暴露出来 ...

  7. selenium学习之基本操作(一)

    通过selenium的使用可以驱动浏览器来模拟加载网页,简单定位元素和获取对应的数据:# find_elements_by_id #(根据id属性值获取元素列表)# find_elements_by_ ...

  8. DMZ是什么

    刚刚接触安全域,实在是佩服自己真的是菜,,,啥都不懂,看看过段时间能有多大进步吧... 概念 DMZ:它是一个缓冲区,一个隔离区.它是位于两台防火墙之间的区域,相对于INTER网来说安全级别高一些,但 ...

  9. Oracle 按不同时间分组统计

    1.按年 select to_char(record_date,'yyyy'), sum(col_8) as total_money from table_name where group by to ...

  10. ConcurrentHashMap源码解析,多线程扩容

    前面一篇已经介绍过了 HashMap 的源码: HashMap源码解析.jdk7和8之后的区别.相关问题分析 HashMap并不是线程安全的,他就一个普通的容器,没有做相关的同步处理,因此线程不安全主 ...