結果

問題 No.274 The Wall
ユーザー kosakkunkosakkun
提出日時 2016-11-29 17:53:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,950 bytes
コンパイル時間 1,077 ms
コンパイル使用メモリ 102,380 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 15:17:35
合計ジャッジ時間 1,918 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 3 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    int N,M; cin>>N>>M;
    vector<int> L(N),R(N);
    REP(i,N)cin>>L[i]>>R[i];
    
    ll sum=0;
    REP(i,N)sum+=abs(L[i]-R[i])+1;
    if(sum>M){
        cout<<"NO"<<endl;
        return 0;
    }
    
    vector< pair<int,pair<int,int> > > dist;
    int center=((M%2==0)?M/2:M/2+1);
    REP(i,N){
        dist.push_back(make_pair(min(abs(L[i]-center),abs(R[i]-center)),make_pair(L[i],R[i])));
    }
    
    sort(dist.begin(),dist.end());
    
    //REP(i,N)cout<<dist[i].first<<endl;
    
    
    int used_L=0,used_R=0;
    
    REP(i,N){
        cout<<used_L<<" "<<used_R<<endl;
        if(i==0){
            used_L=abs(dist[i].second.first);
            used_R=abs(dist[i].second.second);
        }else if(used_R<used_L){
            if(dist[i].first<=used_R){
                cout<<"NO"<<endl;
                return 0;
            }else{
                used_R=dist[i].first;
            }
        }else{
            if(dist[i].first<=used_L){
                cout<<"NO"<<endl;
                return 0;
            }else{
                used_L=dist[i].first;
            }
        }
    }
    
    cout<<"YES"<<endl;
    
    return 0;
}

0