제출 #1335626

#제출 시각아이디문제언어결과실행 시간메모리
1335626tsengangExam (eJOI20_exam)C++20
0 / 100
109 ms104076 KiB
#include <bits/stdc++.h>
#define ll int
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define ertunt return
using namespace std;
ll mod = 1e9+7;
vector<ll> adj[600007];
vector<ll>vis(200005);
vector<ll> f(600005), inv(600005);
ll modpow(ll a, ll b){
    ll r = 1;
    while(b){
        if(b & 1){
            r *= a;
            r %= mod;
        }
        a *= a;
        a %= mod;
        b >>= 1;
    }
    ertunt r;
}
ll nCk(ll n, ll k){
    if(k < 0 || k > n) ertunt 0;
    ertunt f[n] * inv[k] % mod * inv[n - k] % mod;
}
int main(){
	ll n;
	cin >> n;
	vector<ll>a(n+2,1e14),b(n+2,1e14);
	for(ll i = 1; i <= n; i++)cin >> a[i];
	for(ll i = 1; i <= n; i++)cin >> b[i];
	stack<ll>s;
	vector<ll>l(n+2),r(n+2);
	for(ll i = 1; i <= n; i++){
		while(!s.empty() and a[s.top()] <= a[i]) s.pop();
		if(s.empty()) l[i] = -1;
		else l[i] = s.top();
		s.push(i);
	}
	while(!s.empty()) s.pop();
	for(ll i = n; i > 0; i--){
		while(!s.empty() and a[s.top()] <= a[i]) s.pop();
		if(s.empty()) r[i] = n;
		else r[i] = s.top();
		s.push(i);
	}
	vector<vector<ll>>dp(n+1,vector<ll>(n+1));
	for(ll i = 1; i <= n; i++){
		for(ll j = 1; j <= n; j++){
			dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
			if(a[i-1] == b[j] and l[i] < j-1 and j < r[i]){
				dp[i][j] = max(dp[i][j],dp[i][j-1]+1);
			}
		}
	}
	cout << dp[n][n];
}

컴파일 시 표준 에러 (stderr) 메시지

exam.cpp: In function 'int main()':
exam.cpp:33:25: warning: overflow in conversion from 'double' to 'std::vector<int>::value_type' {aka 'int'} changes value from '1.0e+14' to '2147483647' [-Woverflow]
   33 |         vector<ll>a(n+2,1e14),b(n+2,1e14);
      |                         ^~~~
exam.cpp:33:37: warning: overflow in conversion from 'double' to 'std::vector<int>::value_type' {aka 'int'} changes value from '1.0e+14' to '2147483647' [-Woverflow]
   33 |         vector<ll>a(n+2,1e14),b(n+2,1e14);
      |                                     ^~~~
#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...