Submission #97420

#TimeUsernameProblemLanguageResultExecution timeMemory
97420silxikysExhibition (JOI19_ho_t2)C++14
50 / 100
1056 ms6580 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int maxn = 1e5+5; int N, M; int frames[maxn]; int dp[maxn]; int lastused[maxn]; int main() { cin >> N >> M; vector<pair<int,int>> pictures; for (int i = 0; i < N; i++) { int a, b; cin >> a >> b; pictures.push_back({a,b}); } //coordinate compress values sort(pictures.begin(),pictures.end(),[](auto a, auto b) { return a.second < b.second; }); map<int,int> comp; int c = 1; for (auto& p: pictures) { if (comp.count(p.second)) p.second = comp[p.second]; else p.second = comp[p.second] = c++; } sort(pictures.begin(),pictures.end(),[](auto a, auto b) { if (a.second != b.second) return a.second < b.second; return a.first < b.first; }); for (int i = 1; i <= M; i++) cin >> frames[i]; sort(frames+1,frames+M+1); int ans = 0; for (int i = N - 1; i >= 0; i--) { int sz = pictures[i].first; int val = pictures[i].second; if (frames[M] >= sz) dp[i] = 1; for (int j = i + 1; j < N; j++) { if (dp[j] < M && frames[M-dp[j]] >= sz) { dp[i] = max(dp[i],dp[j]+1); } } //cout << i << ": " << dp[i] << '\n'; ans = max(ans,dp[i]); } cout << ans << '\n'; }

Compilation message (stderr)

joi2019_ho_t3.cpp: In function 'int main()':
joi2019_ho_t3.cpp:39:13: warning: unused variable 'val' [-Wunused-variable]
         int val = pictures[i].second;
             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...