Submission #139695

# Submission time Handle Problem Language Result Execution time Memory
139695 2019-08-01T09:11:17 Z mechfrog88 Exhibition (JOI19_ho_t2) C++14
50 / 100
299 ms 274436 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));
    ll ans = 0;
    for (int x=0;x<m;x++){
        if (frame[x] >= arr[0].s){
            dp[0][x] = 1;
        } else {
            dp[0][x] = 0;
        }
        ans = max(ans,dp[0][x]);
    }
    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 (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 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 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 256 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
# 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 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 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 256 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 13 ms 8312 KB Output is correct
21 Correct 13 ms 8312 KB Output is correct
22 Correct 13 ms 8312 KB Output is correct
23 Correct 13 ms 8312 KB Output is correct
24 Correct 13 ms 8272 KB Output is correct
25 Correct 13 ms 8184 KB Output is correct
26 Correct 13 ms 8312 KB Output is correct
27 Correct 13 ms 8312 KB Output is correct
28 Correct 13 ms 8312 KB Output is correct
29 Correct 13 ms 8312 KB Output is correct
30 Correct 13 ms 8312 KB Output is correct
31 Correct 13 ms 8312 KB Output is correct
32 Correct 2 ms 504 KB Output is correct
33 Correct 2 ms 380 KB Output is correct
34 Correct 6 ms 2680 KB Output is correct
35 Correct 3 ms 632 KB Output is correct
36 Correct 14 ms 8348 KB Output is correct
37 Correct 13 ms 8312 KB Output is correct
# 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 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 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 256 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 13 ms 8312 KB Output is correct
21 Correct 13 ms 8312 KB Output is correct
22 Correct 13 ms 8312 KB Output is correct
23 Correct 13 ms 8312 KB Output is correct
24 Correct 13 ms 8272 KB Output is correct
25 Correct 13 ms 8184 KB Output is correct
26 Correct 13 ms 8312 KB Output is correct
27 Correct 13 ms 8312 KB Output is correct
28 Correct 13 ms 8312 KB Output is correct
29 Correct 13 ms 8312 KB Output is correct
30 Correct 13 ms 8312 KB Output is correct
31 Correct 13 ms 8312 KB Output is correct
32 Correct 2 ms 504 KB Output is correct
33 Correct 2 ms 380 KB Output is correct
34 Correct 6 ms 2680 KB Output is correct
35 Correct 3 ms 632 KB Output is correct
36 Correct 14 ms 8348 KB Output is correct
37 Correct 13 ms 8312 KB Output is correct
38 Runtime error 299 ms 274436 KB Execution killed with signal 9 (could be triggered by violating memory limits)
39 Halted 0 ms 0 KB -