Submission #386810

#TimeUsernameProblemLanguageResultExecution timeMemory
386810cpp219Exhibition (JOI19_ho_t2)C++14
100 / 100
233 ms11356 KiB
#pragma GCC optimization "Ofast" #pragma GCC optimization "unroll-loop" #pragma GCC target ("avx2") #include <bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; const ll N = 3e5 + 6; const ll Log2 = 19; const ll inf = 1e16 + 7; typedef pair<ll,ll> LL; vector<ll> v; ll n,m,c[N],bit[N],dp[N]; LL a[N]; ll Find(ll x){ return lower_bound(v.begin(),v.end(),x) - v.begin() + 1; } void compress(){ sort(v.begin(),v.end()); v.resize(unique(v.begin(),v.end()) - v.begin()); for (ll i = 1;i <= n;i++) a[i].fs = Find(a[i].fs),a[i].sc = Find(a[i].sc); for (ll i = 1;i <= m;i++) c[i] = Find(c[i]); } bool lf(LL x,LL y){ return x.sc < y.sc||(x.sc == y.sc && x.fs < y.fs); } void upd(ll p,ll val){ for (ll i = p;i < N;i += i & -i) bit[i] = max(bit[i],val); } ll Get(ll p){ ll res = 0; for (ll i = p;i > 0;i -= i & -i) res = max(res,bit[i]); return res; } /// fs size sc value bool chk(ll mid){ memset(bit,0,sizeof(bit)); ll start = m - mid + 1; for (ll i = 1;i <= n;i++){ ll p = Get(a[i].sc) + 1; dp[i] = 0; if (c[start + p - 1] >= a[i].fs) dp[i] = p; upd(a[i].sc,dp[i]); if (dp[i] >= mid) return 1; } return 0; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); #define task "test" if (fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } cin>>n>>m; for (ll i = 1;i <= n;i++) cin>>a[i].fs>>a[i].sc,v.push_back(a[i].fs),v.push_back(a[i].sc); for (ll i = 1;i <= m;i++) cin>>c[i],v.push_back(c[i]); compress(); sort(a + 1,a + n + 1,lf); sort(c + 1,c + m + 1); ll l,mid,h; //cout<<chk(2); return 0; l = 0; h = m; while(l <= h){ mid = (l + h)/2; if (chk(mid)) l = mid + 1; else h = mid - 1; } cout<<h; }

Compilation message (stderr)

joi2019_ho_t2.cpp:1: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    1 | #pragma GCC optimization "Ofast"
      | 
joi2019_ho_t2.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      | 
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:65:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   65 |     for (ll i = 1;i <= m;i++) cin>>c[i],v.push_back(c[i]); compress();
      |     ^~~
joi2019_ho_t2.cpp:65:60: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   65 |     for (ll i = 1;i <= m;i++) cin>>c[i],v.push_back(c[i]); compress();
      |                                                            ^~~~~~~~
joi2019_ho_t2.cpp:60:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   60 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   61 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...