Submission #441498

#TimeUsernameProblemLanguageResultExecution timeMemory
441498elazarkorenExam (eJOI20_exam)C++17
0 / 100
29 ms332 KiB
#include <iostream> #include <vector> #include <algorithm> #include <stack> #define x first #define y second //#define int long long using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pii> vii; const int MAX_N = 1e5 + 1; int a[MAX_N], b[MAX_N]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; int ans = a[0] == b[0]; for (int i = 1; i < n; i++) { int count = a[i] == b[i]; int best_count = a[i] == b[i], ind = i; for (int j = i - 1; j >= 0; j--) { if (a[j] == b[j]) count--; if (a[i] == b[j]) count++; if (count > best_count) { best_count = count; ind = j; } } for (int j = i - 1; j >= ind; j--) a[j] = a[i]; ans += best_count; } cout << ans; }
#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...