結果

問題 No.808 Kaiten Sushi?
ユーザー rickythetarickytheta
提出日時 2019-03-22 22:51:48
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,620 bytes
コンパイル時間 1,343 ms
コンパイル使用メモリ 162,276 KB
実行使用メモリ 6,696 KB
最終ジャッジ日時 2023-10-19 10:03:31
合計ジャッジ時間 4,050 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,868 KB
testcase_01 AC 2 ms
5,868 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,868 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
5,868 KB
testcase_07 AC 3 ms
5,876 KB
testcase_08 AC 2 ms
5,880 KB
testcase_09 WA -
testcase_10 AC 3 ms
5,880 KB
testcase_11 AC 3 ms
5,876 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
5,872 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
5,868 KB
testcase_21 AC 2 ms
5,868 KB
testcase_22 AC 2 ms
5,868 KB
testcase_23 AC 18 ms
6,168 KB
testcase_24 AC 15 ms
6,108 KB
testcase_25 AC 16 ms
6,148 KB
testcase_26 AC 16 ms
6,132 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 44 ms
6,664 KB
testcase_33 AC 23 ms
6,260 KB
testcase_34 AC 26 ms
6,320 KB
testcase_35 AC 32 ms
6,436 KB
testcase_36 WA -
testcase_37 AC 2 ms
5,868 KB
testcase_38 AC 2 ms
5,868 KB
testcase_39 WA -
testcase_40 AC 10 ms
6,040 KB
testcase_41 AC 12 ms
6,060 KB
testcase_42 WA -
testcase_43 AC 16 ms
6,124 KB
testcase_44 AC 26 ms
6,320 KB
testcase_45 AC 15 ms
6,124 KB
testcase_46 AC 9 ms
6,012 KB
testcase_47 AC 44 ms
6,672 KB
testcase_48 AC 44 ms
6,672 KB
testcase_49 WA -
testcase_50 AC 44 ms
6,672 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 2 ms
5,868 KB
testcase_55 AC 2 ms
5,868 KB
testcase_56 AC 2 ms
5,868 KB
testcase_57 AC 11 ms
6,136 KB
testcase_58 AC 18 ms
6,280 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:40:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 |   scanf("%d%d",&n,&l);
      |   ~~~~~^~~~~~~~~~~~~~
main.cpp:41:16: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   41 |   REP(i,n)scanf("%d",x+i);
      |           ~~~~~^~~~~~~~~~
main.cpp:42:16: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   42 |   REP(i,n)scanf("%d",y+i);
      |           ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,l;
int x[125252], y[125252];
int p[252521];
int sum[252521];

int main(){
  scanf("%d%d",&n,&l);
  REP(i,n)scanf("%d",x+i);
  REP(i,n)scanf("%d",y+i);
  REP(i,n)p[i] = 2*x[i]+0;
  REP(i,n)p[i+n] = 2*y[i]+1;
  sort(p,p+n+n);
  REP(i,2*n)sum[i+1] = sum[i]+(p[i]%2==0 ? 1 : -1);
  int s=0, t=0;
  REP(i,2*n+1){
    if(sum[i]>=sum[s])s=i;
    if(sum[i]<sum[t])t=i;
  }
  ll ans = (ll)l * (max(0,sum[s]-1) + (-sum[t]));
  if(sum[s] > -sum[t] || (sum[s]==-sum[t] && s>t)){
    s--;
    int id = -1;
    FOR(i,s+1,2*n)if(p[i]%2==1){
      id = i; break;
    }
    if(id==-1){
      ans += l;
      REP(i,s)if(p[i]%2==1){
        id = i; break;
      }
    }
    ans += p[id]/2;
    printf("%lld\n",ans);
  }else{
    t--;
    ans += p[t]/2;
    printf("%lld\n",ans);
  }
  return 0;
}
0