結果

問題 No.3385 Up Down Hiking (C++)
コンテスト
ユーザー alcea
提出日時 2025-11-19 01:54:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 387 bytes
コンパイル時間 1,895 ms
コンパイル使用メモリ 200,428 KB
実行使用メモリ 12,264 KB
最終ジャッジ日時 2025-11-22 12:34:29
合計ジャッジ時間 8,697 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 43
権限があれば一括ダウンロードができます
コンパイルメッセージ
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+n-h]+(p[u+h]=max(p[u+h],p[j+h]+1)));
  cout<<k-1<<"\n";
}
0