답안 #519326

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
519326 2022-01-26T07:58:22 Z abcxyz Arcade (NOI20_arcade) C++14
0 / 100
1 ms 332 KB
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
using namespace std;

#define ll long long

bool isvalid(int i, int j, int n, int m){
	if(i<0||i>m-1||j<0||j>n-1){
		return false;}
	else{
		return true;}
}

void solve(){
	int n, m;
	cin>>n>>m;
	vector<pair<int,int>>a(m);
	for(int i = 0; i<m; i++){
		cin >> a[i].first;}
	for(int i = 0; i<m; i++){
		cin >> a[i].second;}
	sort(a.begin(),a.end());
	int v[m] = {0};
	int dp[m][m] = {};
	for(int i = 0; i<m; i++){
		dp[0][i] = 1;}
	bool flag= true;
	for(int i = 1; i<m; i++){
		for(int j = 0; j<m; j++){
			if(isvalid(i-1, j-1, m, m)){
				if(dp[i-1][j-1]==1){
					dp[i][j]=1;
					continue;}}
			if(isvalid(i-1, j, m, m)){
				if(dp[i-1][j]==0){
					continue;}}
			flag = true;
			for(int k = i; k>=0; k--){
				if(!flag){
					break;}
				for(int r = j; r>=0; r--){
					if(v[r]==0){
						v[r]=k;
					    break;}
					else if(abs(a[v[r]].first-a[k].first)>=abs(a[v[r]].second-a[k].second)){
						v[r]=k;
					    break;}
					else if(r==0){
						flag = false;
						break;}}}
			fill(v, v+m, 0);
			if(flag){
				dp[i][j]=1;}
		}
	}

	
    for(int j = 0; j<m; j++){
			if(dp[m-1][j]==1){
				cout<<j+1;
				break;}}
    }


int main(){
	int t;
	//cin>>t;
	t = 1;
	for(int i = 0; i<t; i++){
		solve();
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 288 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Incorrect 0 ms 292 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 288 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Incorrect 0 ms 292 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 288 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Incorrect 0 ms 292 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 288 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Incorrect 0 ms 292 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 288 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Incorrect 0 ms 292 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 288 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Incorrect 0 ms 292 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 288 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Incorrect 0 ms 292 KB Output isn't correct
12 Halted 0 ms 0 KB -