Submission #771956

#TimeUsernameProblemLanguageResultExecution timeMemory
771956I_Love_EliskaM_Exam (eJOI20_exam)C++14
12 / 100
16 ms2688 KiB
// 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) { map<int,int> pos; forn(i,n) pos[a[i]]=i; forn(i,n) { for (int j=i; j<n; ++j) { dp[i+1][j]=max(dp[i+1][j],dp[i][j]+(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(1); } 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 (stderr)

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 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...