Submission #1143997

#TimeUsernameProblemLanguageResultExecution timeMemory
1143997minggaExhibition (JOI19_ho_t2)C++20
100 / 100
30 ms8264 KiB
#include "bits/stdc++.h" using namespace std; #define ln "\n" #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define int long long const int mod = 1e9 + 7; const int inf = 2e18; const int N = 1e5 + 7; int n, m; struct picture { int s, v; bool operator < (const picture& o) const { if(v == o.v) return s < o.s; return v < o.v; } } a[N]; int b[N]; namespace sub2 { bool check() { return n <= 1000 and m <= 1000; } int dp[1005][1005]; void solve() { for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]); if(b[j] >= a[i].s) { dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1); } } } cout << dp[n][m] << ln; } } namespace full { void solve() { int ans = 0; for(int i = n, j = m; i > 0 and j > 0; i--) { if(a[i].s <= b[j]) { ans++; j--; } } cout << ans << ln; } } signed main() { cin.tie(0) -> sync_with_stdio(0); #define task "" if(fopen(task ".INP", "r")) { freopen(task ".INP", "r", stdin); freopen(task ".OUT", "w", stdout); } cin >> n >> m; for(int i = 1; i <= n; i++) { cin >> a[i].s >> a[i].v; } for(int i = 1; i <= m; i++) cin >> b[i]; sort(b + 1, b + m + 1); sort(a + 1, a + n + 1); if(sub2::check()) sub2::solve(); else full::solve(); cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC; }

Compilation message (stderr)

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:61:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |                 freopen(task ".INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:62:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |                 freopen(task ".OUT", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...