# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1112175 | PagodePaiva | Fortune Telling 2 (JOI14_fortune_telling2) | C++17 | 3068 ms | 2440 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int N = 40010;
int dp[N][2];
int main(){
int n, k;
cin >> n >> k;
vector <pair <long long,long long>> v;
for(int i = 1;i <= n;i++){
long long a, b;
cin >> a >> b;
v.push_back({a, b});
}
vector <long long> qr;
for(int i = 1;i <= k;i++){
long long x;
cin >> x;
qr.push_back(x);
}
long long res = 0;
for(int i = 1;i <= n;i++){
dp[k][0] = dp[k][1] = 0;
for(int j = k-1;j >= 0;j--){
dp[j][0] = (min(v[i-1].first, v[i-1].second) <= qr[j] ? dp[j+1][1]+1 : dp[j+1][0]);
dp[j][1] = (max(v[i-1].first, v[i-1].second) <= qr[j] ? dp[j+1][0]+1 : dp[j+1][1]);
}
int a = v[i-1].first, b = v[i-1].second;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |