# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
624250 |
2022-08-07T14:52:03 Z |
Mounir |
Exam (eJOI20_exam) |
C++14 |
|
1000 ms |
1072 KB |
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define chmax(x, v) x = max(x, v)
#define chmin(x, v) x = min(x, v)
#define pb push_back
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define x first
#define y second
#define int long long
using namespace std;
signed main(){
int nVals; cin >> nVals;
vector<int> init(nVals), requis(nVals);
for (int& val : init) cin >> val;
for (int& val : requis) cin >> val;
vector<int> dp(nVals + 1, 0);
int bestRes = -1;
for (int fin = 0; fin < nVals; ++fin){
map<int, int> nOccs, nVraisAvant;
int maxi = -1, sum = 0;
for (int deb = fin; deb >= 0; --deb){
nOccs[requis[deb]]++;
nVraisAvant[requis[deb]] += (requis[deb] == init[deb]);
sum += (requis[deb] == init[deb]);
chmax(maxi, init[deb]);
int gainTrans = nOccs[maxi] - sum + nVraisAvant[maxi];
chmax(dp[fin + 1], dp[deb] + gainTrans);
}
chmax(bestRes, dp[fin + 1]);
// chmax(dp[fin])
}
cout << bestRes << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1090 ms |
1072 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1082 ms |
668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |