题目链接

交互题。

题意:给你三个数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的更多相关文章

  1. Codeforces Round #449 (Div. 2)

    Codeforces Round #449 (Div. 2) https://codeforces.com/contest/897 A #include<bits/stdc++.h> us ...

  2. Codeforces Round #449 (Div. 2)ABCD

    又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...

  3. 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 ...

  4. 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 ...

  5. Codeforces Round #449 Div. 1

    B:注意到nc/2<=m,于是以c/2为界决定数放在左边还是右边,保证序列满足性质的前提下替换掉一个数使得其更靠近边界即可. #include<iostream> #include& ...

  6. 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: ...

  7. Codeforces Round #449 (Div. 1)C - Willem, Chtholly and Seniorious

    ODT(主要特征就是推平一段区间) 其实就是用set来维护三元组,因为数据随机所以可以证明复杂度不超过O(NlogN),其他的都是暴力维护 主要操作是split,把区间分成两个,用lowerbound ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. VScode:保存格式化问题,ESLint插件和编辑器本身冲突

    我喜欢使用ESLint来保持我的代码的规范性,但是最近遇到问题:就是ctrl+s后变得如下: 我已经解决了:发现原来是编辑器本身的格式化和插件带的格式化起冲突,因为我把两者同时启用:FormatOnS ...

  2. 26 python 初学(线程、同步锁、死锁和递归锁)

    参考博客: www.cnblogs.com/yuanchenqi/articles/5733873.html 并发:一段时间内做一些事情 并行:同时做多件事情 线程是操作系统能够进行运算调度的基本单位 ...

  3. AI deeplab

    参考链接: https://arxiv.org/pdf/1412.7062v3.pdf

  4. System.Threading.Timer如何正确地被Dispose

    System.Threading.Timer是.NET中一个定时触发事件处理方法的类(本文后面简称Timer),它背后依靠的是.NET的线程池(ThreadPool),所以当Timer在短时间内触发了 ...

  5. React-使用装饰器

    create-react-app默认不支持装饰器的,需要做以下配置. 打开 package.json ,可以看到eject.运行 npm run eject 可以让由create-react-app创 ...

  6. mm-wiki安装部署

    参考连接:https://github.com/skyhack1212/mm-wiki 打开 https://github.com/phachon/mm-wiki/releases 找到对应平台的版本 ...

  7. 解决 AttributeError: 'ForeignKey' object has no attribute 're'

    解决办法 # print('rel...',filter_field_obj.re.to.objects.all()) print("rel...", filter_field_o ...

  8. keepalived--小白博客

    一.HA集群中的相关术语 1.节点(node) 运行HA进程的一个独立主机,称为节点,节点是HA的核心组成部分,每个节点上运行着操作系统和高可用软件服务,在高可用集群中,节点有主次之分,分别称之为主节 ...

  9. H5 百度一下,你就知道

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  10. 通过sort()方法实现升序和降序排列

    数组 升序:Arrays.sort(arr); 降序: 方法一:Arrays.sort(arr,Collections.reverseOrder()); 方法二: package com.yh.sor ...