Submission #391571

#TimeUsernameProblemLanguageResultExecution timeMemory
391571maomao90Arcade (NOI20_arcade)C++14
51 / 100
1098 ms259768 KiB
#include <bits/stdc++.h> 
using namespace std;

#define mnto(x, y) x = min(x, (__typeof__(x)) y)
#define mxto(x, y) x = max(x, (__typeof__(x)) y)
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define MP make_pair
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define MT make_tuple
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define pb emplace_back
typedef vector<int> vi;
typedef vector<ii> vii;

#define INF 1000000005
#define LINF 1000000000000000005
#define MOD 1000000007
#define MAXN 500005

int n, m;
ii ta[MAXN];
vi adj[MAXN];
int p[MAXN * 2];
int mcbm;

bool visited[MAXN];
bool dfs(int u) {
	for (int v : adj[u]) {
		if (visited[v]) continue;
		visited[v] = 1;
		if (p[v] == -1 || dfs(p[v])) {
			p[v] = u;
			return 1;
		}
	}
	return 0;
}

bool isPos(int i, int j) {
	return ta[j].FI - ta[i].FI >= abs(ta[j].SE - ta[i].SE);
}

int main() {
	scanf("%d%d", &n, &m);
	REP (i, 0, m) {
		scanf("%d", &ta[i].FI);
	}
	REP (i, 0, m) {
		scanf("%d", &ta[i].SE);
	}
	sort(ta, ta + m);
	REP (i, 0, m) {
		REP (j, i + 1, m) {
			if (isPos(i, j)) {
				//printf("%d %d\n", i, j);
				adj[i].pb(j + m);
			}
		}
	}
	memset(p, -1, sizeof p);
	REP (i, 0, m) {
		REP (j, 0, m * 2) {
			visited[j] = 0;
		}
		if (dfs(i)) {
			mcbm++;
		}
	}
	printf("%d\n", m - mcbm);
	return 0;
}

Compilation message (stderr)

Arcade.cpp: In function 'int main()':
Arcade.cpp:51:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   51 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
Arcade.cpp:53:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   53 |   scanf("%d", &ta[i].FI);
      |   ~~~~~^~~~~~~~~~~~~~~~~
Arcade.cpp:56:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   56 |   scanf("%d", &ta[i].SE);
      |   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...