Submission #1143991

#TimeUsernameProblemLanguageResultExecution timeMemory
1143991minggaExhibition (JOI19_ho_t2)C++20
0 / 100
0 ms324 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 {
		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() {
		sort(b + 1, b + m + 1);
		sort(a + 1, a + n + 1);
		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;
	}
}

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];
	if(sub2::check()) sub2::solve();
	cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}

Compilation message (stderr)

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