結果
| 問題 |
No.3385 Up Down Hiking (C++)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-18 23:30:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 138 ms / 2,000 ms |
| コード長 | 519 bytes |
| コンパイル時間 | 1,720 ms |
| コンパイル使用メモリ | 201,144 KB |
| 実行使用メモリ | 12,156 KB |
| 最終ジャッジ日時 | 2025-11-22 12:33:52 |
| 合計ジャッジ時間 | 8,304 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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(){
| ^~~~
ソースコード
#import<bits/stdc++.h>
using namespace std;
long n,m,h[1<<17],i,u,v,x[1<<17],k=-1,z,t,l,d=1<<17,I;
vector<int>G[1<<17],p(1<<18,-1e9);
main(){
cin>>n>>m;
for(i=0;i<n;i++){
cin>>h[i];
x[i]=h[i]*d+i;
}
for(;cin>>u>>v;){
u--;v--;
if(h[u]<h[v]) swap(u,v);
G[u].push_back(v);
}
sort(x,x+n);
p[0]=p[d+n-1]=0;
for(i=0;i<n;i++){
I=x[i]%d;
for(int j:G[I])
for(t=0;t<2*d;t+=d)
p[t+I]=max(p[t+I],p[t+j]+1);
l=p[I]+p[I+d]+1;
if(k<l)
k=l;
}
cout<<k<<endl;
}