Submission #771959

# Submission time Handle Problem Language Result Execution time Memory
771959 2023-07-03T12:48:29 Z I_Love_EliskaM_ Exam (eJOI20_exam) C++14
25 / 100
97 ms 118676 KB
//  Esti <3

//\
     šťastia pre nás :)
//   you're already the best
//             _
//   ^ ^      //
// >(O_O)<___//
//   \ __ __  \
//    \\ \\ \\\\
 
#include <bits/stdc++.h>
using namespace std;
 
//#pragma GCC optimize("O3","unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
 
#pragma GCC optimize("O3")
#pragma GCC target("popcnt")

using ll = long long;
#define int long long
#define forn(i,n) for(int i=0; i<(n); ++i)
#define pb push_back
#define pi pair<int,int>
#define f first
#define s second 
#define vii(a,n) vector<int> a(n); forn(i,n) cin>>a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
 
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e18;
const int mod = 1e9+7;//998244353;
 
// \
\
:smiling_face_with_3_hearts: :smiling_face_with_3_hearts:  :smiling_face_with_3_hearts:  
 
//vidime sa veľmi skoro, moje slnko

void p2(vector<int>&a, vector<int>&b, int n) {
	vector<int> vis(n,0);
	int ans=0;
	forn(i,n) {
		if (vis[i]) continue;
		if (a[i]!=b[i]) continue;
		++ans;
		for (int l=i-1; l>=0; --l) {
			if (a[l]>b[l]) break;
			++ans;
		}
		for (int r=i+1; r<n; ++r) {
			if (a[r]>b[r]) break;
			++ans;
			vis[r]=1;
		}
	}
	cout<<ans<<'\n';
	exit(0);
}

const int N=5555;
int dp[N][N];

void p3(vector<int> a, vector<int> b, int n) {
	forn(i,n) {
		int mx=0;
		forn(j,i) mx=max(mx,dp[i][j]);
		for (int j=i; j<n; ++j) {
			mx=max(mx,dp[i][j]);
			dp[i+1][j]=max(dp[i+1][j],mx+(b[i]==a[j]));
			//if (j) dp[i+1][j]=max(dp[i+1][j],dp[i][j-1]+(b[i]==a[j]));
		}
		//forn(j,n) cout<<dp[i+1][j]<<' '; cout<<'\n';
	}
	cout<<dp[n][n-1]<<'\n';
	exit(0);
}

void solve() {

	int n; cin>>n;
	vii(a,n);
	vii(b,n);

	int z=1; forn(i,n) z&=b[i]==b[0];
	if (z) p2(a,b,n);
	
	z=n<=5000; forn(i,n-1) z&=a[i]<a[i+1];
	if (z) p3(a,b,n);

}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t=1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Compilation message

exam.cpp:3:1: warning: multi-line comment [-Wcomment]
    3 | //\
      | ^
exam.cpp:9:1: warning: multi-line comment [-Wcomment]
    9 | //   \ __ __  \
      | ^
exam.cpp:36:1: warning: multi-line comment [-Wcomment]
   36 | // \
      | ^
# 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 Correct 1 ms 340 KB Output is correct
2 Correct 4 ms 972 KB Output is correct
3 Correct 12 ms 2584 KB Output is correct
4 Correct 9 ms 2828 KB Output is correct
5 Correct 17 ms 2912 KB Output is correct
6 Correct 9 ms 2852 KB Output is correct
7 Correct 10 ms 2900 KB Output is correct
8 Correct 16 ms 2888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 3284 KB Output is correct
3 Correct 20 ms 24152 KB Output is correct
4 Correct 90 ms 110148 KB Output is correct
5 Correct 97 ms 118676 KB Output is correct
6 Correct 94 ms 118576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Output isn't correct
2 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 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -