Submission #139693

# Submission time Handle Problem Language Result Execution time Memory
139693 2019-08-01T09:06:27 Z mechfrog88 Exhibition (JOI19_ho_t2) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;

struct pic{
    ll v,s;
    bool operator <(const pic& rhs) const{
        if (v == rhs.v){
            return s < rhs.s;
        }
        return v < rhs.v;
    }
};


vector <pic> arr;
vector <ll> frame;

ll ans = 0;
ll n,m;

void func(ll i,vector<ll>s){
    if (i == n){
        ll j = 0;
        for (ll z=0;z<s.size() && j < m;z++,j++){
            while (j < m && s[z] > frame[j]){
                j++;
            }
            if (j < m) ans = max(ans,z+1);
        }
        return;
    }
    func(i+1,s);
    s.push_back(arr[i].s);
    func(i+1,s);
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    arr.resize(n);
    for (int z=0;z<n;z++){
        cin >> arr[z].s >> arr[z].v;
    }
    frame.resize(m);
    for (int z=0;z<m;z++){
        cin >> frame[z];
    }
    sort(arr.begin(),arr.end());
    sort(frame.begin(),frame.end());
    vector <vector<ll>> dp(n,vector<ll>(m,0));
    for (int x=0;x<m;x++){
        if (frame[x] >= arr[0].s){
            dp[0][x] = 1;
        } else {
            dp[0][x] = 0;
        }
    }
    ll ans = 0;
    for (int z=1;z<n;z++){
        ll mx = 0;
        for (int x=0;x<m;x++){
            dp[z][x] = dp[z-1][x];
            if (x > 0){
                dp[z][x] = max(dp[z][x],dp[z][x-1]);
            }
            if (x > 0 && frame[x] >= arr[z].s){
                dp[z][x] = max(dp[z][x],mx+1);
            }
            ans = max(ans,dp[z][x]);
            mx = max(dp[z-1][x],mx);
        }
    }
    cout << ans << endl;
}

Compilation message

joi2019_ho_t2.cpp: In function 'void func(ll, std::vector<long long int>)':
joi2019_ho_t2.cpp:36:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (ll z=0;z<s.size() && j < m;z++,j++){
                     ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Incorrect 2 ms 376 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Incorrect 2 ms 376 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Incorrect 2 ms 376 KB Output isn't correct
15 Halted 0 ms 0 KB -