Submission #446373

#TimeUsernameProblemLanguageResultExecution timeMemory
446373mansurExam (eJOI20_exam)C++17
0 / 100
1081 ms1100 KiB
#include<bits/stdc++.h> #pragma optimize ("g",on) #pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("03") #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native") using namespace std; #define all(a) a.begin(), a.end() #define ll long long #define pb push_back #define nl '\n' #define popb pop_back() #define sz size() #define ld long double #define ull unsigned long long #define F first #define S second #define fix fixed << setprecision #define pii pair<int, int> #define E exit (0) #define int long long const ll inf = (1ll << 62ll), N = 5e5 + 5, mod = 1e9 + 7; signed main() { //freopen("invtrans.in", "r", stdin); //freopen("invtrans.out", "w", stdout); ios_base::sync_with_stdio(NULL); cin.tie(NULL); int n; cin >> n; int a[n + 1], b[n + 1]; int dp[n + 1]; dp[0] = 0; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; for (int i = 1; i <= n; i++) { dp[i] = 0; map<int, int> cnt; int mx = 0; for (int j = i; j >= 1; j--) { mx = max(mx, a[j]); cnt[b[j]]++; dp[i] = max(dp[i], dp[j - 1] + cnt[mx]); } } cout << dp[n]; }

Compilation message (stderr)

exam.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize ("g",on)
      |
#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...