Codeforces Round #449 (Div. 2) D. Ithea Plays With Chtholly
题目链接
交互题。
题意:给你三个数n,m,k.让你完成至多m次互动,每次给你一个q,让你从n个位置选一个位置放这个数,覆盖已经放过的数。让你再m次使得n个位置的数不递减,达到直接退出。
解法:暴力,如果q小于c/2的话,从前往后找,若当前位置没有数或者比q大的话,就直接放再这个位置上,大于c/2的话就从后往前找,若当前位置没有数或者比q小的话就直接放。
如果每个位置都有数的话说明放完了。
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
int ans[20093];
int main(){
ios::sync_with_stdio(false);
int n,m,c;
cin>>n>>m>>c;
for(int i=1;i<=m;i++){
int q;
int ke=0;
for(int j=1;j<=n;j++){
if(!ans[j]){ke=1;break;}
}
if(!ke)break;
cin>>q;
ans[n+1]=2e9;
if(q<=c/2){
int bj=0;
for(int j=1;j<=n;j++){
if(ans[j]==0||ans[j]>q){
ans[j]=q;
cout<<j<<endl;
bj=1;
break;
}
}
if(!bj){ans[n]=q;cout<<1<<endl;}
}else{
int bj=0;
for(int j=n;j>=1;j--){
if(ans[j]==0||ans[j]<q){
ans[j]=q;
bj=1;
cout<<j<<endl;
break;
}
}
if(!bj){ans[1]=q;cout<<1<<endl;}
}
fflush(stdout);
}
return 0;
}
Codeforces Round #449 (Div. 2) D. Ithea Plays With Chtholly的更多相关文章
- Codeforces Round #449 (Div. 2)
Codeforces Round #449 (Div. 2) https://codeforces.com/contest/897 A #include<bits/stdc++.h> us ...
- Codeforces Round #449 (Div. 2)ABCD
又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...
- Codeforces Round #449 (Div. 2) B. Chtholly's request【偶数位回文数】
B. Chtholly's request time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #449 (Div. 2)-897A.Scarborough Fair(字符替换水题) 897B.Chtholly's request(处理前一半) 897C.Nephren gives a riddle(递归)
A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #449 Div. 1
B:注意到nc/2<=m,于是以c/2为界决定数放在左边还是右边,保证序列满足性质的前提下替换掉一个数使得其更靠近边界即可. #include<iostream> #include& ...
- Codeforces Round #449 (Div. 1) Willem, Chtholly and Seniorious (ODT维护)
题意 给你一个长为 \(n\) 的序列 \(a_i\) 需要支持四个操作. \(1~l~r~x:\) 把 \(i \in [l, r]\) 的 \(a_i\) 加 \(x\) . \(2~l~r~x: ...
- Codeforces Round #449 (Div. 1)C - Willem, Chtholly and Seniorious
ODT(主要特征就是推平一段区间) 其实就是用set来维护三元组,因为数据随机所以可以证明复杂度不超过O(NlogN),其他的都是暴力维护 主要操作是split,把区间分成两个,用lowerbound ...
- Codeforces Round #449 (Div. 2) C. DFS
C. Nephren gives a riddle time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- Codeforces Round #449 (Div. 2) A. Scarborough Fair【多次区间修改字符串】
A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
随机推荐
- 3.20 总结 java程序流程控制
- Resolving Issues of "Library Cache Pin" or "Cursor Pin S wait on X" (Doc ID 1476663.1)
Doc ID 1476663.1) To Bottom In this Document Purpose Troubleshooting Steps Brief Definition: ...
- NodeJS之异常处理
1. 为什么要处理异常? 如果我们不处理异常的话,直接会导致程序奔溃,用户体验比较差,因此我们要对异常进行处理,当出现异常的情况下,我们要给用户一个友好的提示,并且记录该异常,方便我们排查. 2. 在 ...
- Guava Cache探索及spring项目整合GuavaCache实例
背景 对于高频访问但是低频更新的数据我们一般会做缓存,尤其是在并发量比较高的业务里,原始的手段我们可以使用HashMap或者ConcurrentHashMap来存储. 这样没什么毛病,但是会面临一个问 ...
- ARC089E GraphXY 构造
传送门 在Luogu上评了"NOI"之后评级变成了"普及+/提高"--我觉得我可能要退群了 考虑构造一个这样的图: 其中上半部分是从\(S\)开始的一条长\(1 ...
- Elastic Stack-Elasticsearch使用介绍(一)
一.前言 Elasticsearch对外提供RESTful API,下面的演示我们主要使用Postman,进行一系列的Demo演示,这款工具方便各位前端大大或者对接口调试的神器: 安装过于简单 ...
- 【刷题】若串 =’software’ ,其子串数目为:37
子串 子串是母串中的一部分,可以是母串本身,也可以是空字符串 设串中字符数为n,则其子串数目为:s=(1+n)*n/2+1 具体地: 长为0的子串:1 长为1的子串:8 长为2的子串:7 长为3的子串 ...
- Redisson 分布式锁
Redisson_百度百科https://baike.baidu.com/item/Redisson/20856570 redission 分布式锁 - 穆穆兔兔 - 博客园https://www.c ...
- 微信小程序开发编程手记20190303
三元表达式: 运算: 引号与花括号之间如果有空格,将被视为字符串: pages页面容器标签: vscode:
- Java多线程9:中断机制
一.概述 之前讲解Thread类中方法的时候,interrupt().interrupted().isInterrupted()三个方法没有讲得很清楚,只是提了一下.现在把这三个方法同一放到这里来讲, ...