結果

問題 No.3385 Up Down Hiking (C++)
コンテスト
ユーザー alcea
提出日時 2025-11-19 01:51:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 383 bytes
コンパイル時間 1,861 ms
コンパイル使用メモリ 200,468 KB
実行使用メモリ 12,304 KB
最終ジャッジ日時 2025-11-22 12:34:25
合計ジャッジ時間 8,274 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 2
other AC * 25 WA * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
    1 | #import<bits/stdc++.h>
      |  ^~~~~~
main.cpp:5:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    5 | main(){
      | ^~~~

ソースコード

diff #
raw source code

#import<bits/stdc++.h>
using namespace std;
long n,m,h,i,u,x[1<<17],k;
vector<long>G[1<<17],p(1<<18,-1e9);
main(){
  for(;cin>>h;)
    n?m?i<n?x[i++]=h*n+i:i++-n&1?x[--u]>x[--h]?:u^=h^=u^=h,G[u].push_back(h),0:u=h:m=h:n=h;
  sort(x,x+n);
  for(p[0]=p[2*n-1]=1,i=0;i<2*n;i++)
    for(int j:G[u=x[i%n]%n])
      h=i/n*n,k=max(k,p[u]+(p[u+h]=max(p[u+h],p[j+h]+1)));
  cout<<k-1<<"\n";
}
0