답안 #1029812

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1029812 2024-07-21T11:02:16 Z ihne Airplane (NOI23_airplane) C++17
63 / 100
112 ms 21332 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
const int mn=2e5+5;
const int mod=1e9+7;
int a[mn];
pii dp[mn];
vector<int> g[mn];
signed main(){
  //freopen("","r",stdin);
  //freopen("","w",stdout);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  int ans=1e18;
  for (int i=1;i<=n;i++){
    cin>>a[i];
    dp[i]={1e18,1e18};
  }
  for (int i=1;i<=m;i++){
    int u,v;
    cin>>u>>v;
    g[u].pb(v);
    g[v].pb(u);
  }
  dp[1]={0,0};
  priority_queue<pair<pii,int>,vector<pair<pii,int>>,greater<pair<pii,int>>> pq;
  pq.push({{0,0},1});
  while (!pq.empty()){
    int lb=pq.top().fi.fi-pq.top().fi.se;
    int ub=pq.top().fi.se;
    int id=pq.top().se;
    pq.pop();
    pii cur={lb+ub,ub};
    if (dp[id]!=cur) continue;
    for (int v:g[id]){
      if (v==n) ans=min(ans,ub+max(lb,1ll));
      else{
        if (a[v]>ub){
          int l=a[v];
          int r=a[v];
          if (l+r<dp[v].fi){
            dp[v]={l+r,r};
            pq.push({{l+r,r},v});
          }
          else if (l+r==dp[v].fi&&r<dp[v].se){
            dp[v]={l+r,r};
            pq.push({{l+r,r},v});
          }
        }
        else{
          int l=max(a[v],lb-1);
          int r=ub+1;
          if (l+r<dp[v].fi){
            dp[v]={l+r,r};
            pq.push({{l+r,r},v});
          }
        }
      }
    }
  }
  cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 49 ms 19284 KB Output is correct
3 Correct 49 ms 19548 KB Output is correct
4 Correct 52 ms 19796 KB Output is correct
5 Correct 52 ms 20308 KB Output is correct
6 Correct 71 ms 20308 KB Output is correct
7 Correct 71 ms 20308 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 3 ms 5212 KB Output is correct
7 Correct 3 ms 5212 KB Output is correct
8 Correct 3 ms 5212 KB Output is correct
9 Correct 4 ms 5212 KB Output is correct
10 Correct 3 ms 5212 KB Output is correct
11 Correct 3 ms 5212 KB Output is correct
12 Correct 3 ms 5212 KB Output is correct
13 Correct 3 ms 5212 KB Output is correct
14 Correct 3 ms 5212 KB Output is correct
15 Correct 3 ms 5280 KB Output is correct
16 Correct 3 ms 5440 KB Output is correct
17 Correct 3 ms 5212 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 3 ms 5212 KB Output is correct
7 Correct 3 ms 5212 KB Output is correct
8 Correct 3 ms 5212 KB Output is correct
9 Correct 4 ms 5212 KB Output is correct
10 Correct 3 ms 5212 KB Output is correct
11 Correct 3 ms 5212 KB Output is correct
12 Correct 3 ms 5212 KB Output is correct
13 Correct 3 ms 5212 KB Output is correct
14 Correct 3 ms 5212 KB Output is correct
15 Correct 3 ms 5280 KB Output is correct
16 Correct 3 ms 5440 KB Output is correct
17 Correct 3 ms 5212 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 3 ms 5212 KB Output is correct
20 Correct 3 ms 5212 KB Output is correct
21 Correct 3 ms 5212 KB Output is correct
22 Correct 3 ms 5212 KB Output is correct
23 Correct 3 ms 5212 KB Output is correct
24 Correct 4 ms 5208 KB Output is correct
25 Correct 4 ms 5212 KB Output is correct
26 Correct 4 ms 5212 KB Output is correct
27 Correct 3 ms 5268 KB Output is correct
28 Correct 4 ms 5212 KB Output is correct
29 Correct 3 ms 5464 KB Output is correct
30 Correct 3 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 49 ms 19284 KB Output is correct
3 Correct 49 ms 19548 KB Output is correct
4 Correct 52 ms 19796 KB Output is correct
5 Correct 52 ms 20308 KB Output is correct
6 Correct 71 ms 20308 KB Output is correct
7 Correct 71 ms 20308 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 3 ms 5212 KB Output is correct
15 Correct 3 ms 5212 KB Output is correct
16 Correct 3 ms 5212 KB Output is correct
17 Correct 4 ms 5212 KB Output is correct
18 Correct 3 ms 5212 KB Output is correct
19 Correct 3 ms 5212 KB Output is correct
20 Correct 3 ms 5212 KB Output is correct
21 Correct 3 ms 5212 KB Output is correct
22 Correct 3 ms 5212 KB Output is correct
23 Correct 3 ms 5280 KB Output is correct
24 Correct 3 ms 5440 KB Output is correct
25 Correct 3 ms 5212 KB Output is correct
26 Correct 2 ms 4956 KB Output is correct
27 Correct 3 ms 5212 KB Output is correct
28 Correct 3 ms 5212 KB Output is correct
29 Correct 3 ms 5212 KB Output is correct
30 Correct 3 ms 5212 KB Output is correct
31 Correct 3 ms 5212 KB Output is correct
32 Correct 4 ms 5208 KB Output is correct
33 Correct 4 ms 5212 KB Output is correct
34 Correct 4 ms 5212 KB Output is correct
35 Correct 3 ms 5268 KB Output is correct
36 Correct 4 ms 5212 KB Output is correct
37 Correct 3 ms 5464 KB Output is correct
38 Correct 3 ms 5212 KB Output is correct
39 Correct 99 ms 21332 KB Output is correct
40 Correct 112 ms 21060 KB Output is correct
41 Correct 81 ms 20820 KB Output is correct
42 Correct 80 ms 20616 KB Output is correct
43 Correct 89 ms 20732 KB Output is correct
44 Correct 81 ms 20564 KB Output is correct
45 Correct 86 ms 20400 KB Output is correct
46 Correct 83 ms 20560 KB Output is correct
47 Correct 85 ms 20560 KB Output is correct
48 Correct 80 ms 20560 KB Output is correct
49 Incorrect 93 ms 21332 KB Output isn't correct
50 Halted 0 ms 0 KB -