Submission #833349

#TimeUsernameProblemLanguageResultExecution timeMemory
833349vjudge1Exam (eJOI20_exam)C++17
25 / 100
25 ms1492 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> const int INF = 2147483645; const int maxN = (int)1e5+5; const ll LLINF = LLONG_MAX; //const ll mod = 998244353; const ll mod = 1000000007; ll dp[maxN]; vector<int> v; ll lis (ll n) { ll mx = 0; for (int i=0; i<n; i++) { for (int j=0; j<i; j++) { if (v[i] >= v[j]) { dp[i] = max(dp[i], dp[j] + 1); } } } for (int i=0;i<n;i++) { mx = max(mx, dp[i]); } return mx+1; } void st3(vector<int> h, vector<int> t) { map<int, int> idx; int n = h.size(); for (int i=0;i<n;i++) idx[h[i]] = i; for (int i=0;i<n;i++) { if (idx.count(t[i]) && i <= idx[t[i]]) v.pb(t[i]); } cout<<lis(v.size()); } void solv() { int n, a, ans=0; vector<int> h, t; bool inc = true; cin>>n; for (int i=0;i<n;i++) { cin>>a, h.pb(a); if (i > 0) { if (a <= h[i-1]) inc = false; } } for (int i=0;i<n;i++) cin>>a, t.pb(a); if (inc) { st3(h, t); return; } for (int i=0;i<n;i++) { if (h[i] != a) continue; int tmp = i-1; while (tmp >= 0 && h[tmp] <= a) { ans++, tmp--; } while (i < n && h[i] <= a) { ans++, i++; } } cout<<ans<<'\n'; } int main() { ios::sync_with_stdio(0); cin.tie(0); int t=1; // cin>>t; while (t--) solv(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...