Submission #1092580

#TimeUsernameProblemLanguageResultExecution timeMemory
1092580Trisanu_DasCat Exercise (JOI23_ho_t4)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define ff first #define ss second int n; vector<pair<int, int>> pos; int f(ll l, ll r, ll nw){ if(r <= l) return abs(nw - r); int ans = 0, ht; for(int i = 0; i < n; i++){ if(l <= pos[i].ss && pos[i].ss <= r){ ht = pos[i].ss; ans += abs(nw - ht); break; } } return ans + max(f(l, ht - 1, ht), f(ht + 1, r, ht)); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; p.resize(n); for(int i=0; i<n; i++){ cin >> pos[i].ff; pos[i].ss = i; } sort(pos.begin(), pos.end(), greater<pair<int, int> >()); int a, b; for(int i = 0; i < n - 1; i++) cin >> a >> b; cout << f(0, n - 1, pos[0].ss) << '\n'; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:26:5: error: 'p' was not declared in this scope
   26 |     p.resize(n);
      |     ^