結果
| 問題 |
No.274 The Wall
|
| コンテスト | |
| ユーザー |
kosakkun
|
| 提出日時 | 2016-11-29 17:53:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,950 bytes |
| コンパイル時間 | 892 ms |
| コンパイル使用メモリ | 102,340 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-27 13:34:34 |
| 合計ジャッジ時間 | 1,657 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 3 |
| other | AC * 7 WA * 15 |
ソースコード
#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;
}
kosakkun