1. 程式人生 > >CodeForce896 B. Ithea Plays With Chtholly

CodeForce896 B. Ithea Plays With Chtholly

#include <bits/stdc++.h>

using namespace std;

const int maxn = 1050 ;
int n , m , c , temp ;
int arr[maxn] ;

int main(){
    int num = 0 ;
    scanf("%d %d %d" , &n , &m , &c) ;
    memset(arr , -1 , sizeof(arr)) ;
    while(m --){
        scanf("%d" , &temp) ;
        if(temp > c / 2){
            for(int i = n ; i >= 1 ; i --){
                if(arr[i] == -1 || arr[i] < temp){
                    if(arr[i] == -1) num ++ ;
                    arr[i] = temp ;
                    printf("%d\n" , i) ;
                    fflush(stdout) ;
                    break ;
                }
            }
        }else{
            for(int i = 1 ; i <= n ; i ++ ){
                if(arr[i] == -1 || arr[i] > temp){
                    if(arr[i] == -1) num ++ ;
                    arr[i] = temp ;
                    printf("%d\n" , i) ;
                    fflush(stdout) ;
                    break ;
                }
            }
        }
        if(num == n) return 0 ;
    }
    return 0 ;
}