結果
| 問題 |
No.3385 Up Down Hiking (C++)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-19 00:20:09 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 147 ms / 2,000 ms |
| コード長 | 440 bytes |
| コンパイル時間 | 1,670 ms |
| コンパイル使用メモリ | 200,360 KB |
| 実行使用メモリ | 12,164 KB |
| 最終ジャッジ日時 | 2025-11-22 12:34:01 |
| 合計ジャッジ時間 | 8,398 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,i,u,v,x[1<<17],k,d=1<<17;
vector<long>G[1<<17],p(1<<18,-1e9);
main(){
for(cin>>n>>m;i<n;i++)
cin>>h,
x[i]=h*d+i;
for(;cin>>u>>v;G[u].push_back(v))
if(x[--u]<x[--v])
swap(u,v);
sort(x,x+n);
for(p[0]=p[d+n-1]=1,i=0;i<2*n;i++){
u=x[i%n]%d;
v=i/n*d;
for(int j:G[u])
p[u+v]=max(p[u+v],p[j+v]+1);
k=max(k,p[u]+p[u+d]);
}
cout<<k-1<<"\n";
}