Submission #98053

# Submission time Handle Problem Language Result Execution time Memory
98053 2019-02-20T04:54:18 Z dndhk None (JOI16_worst_reporter2) C++14
0 / 100
2000 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

#define INF 2000000000

typedef pair<int, int> pii;

const int MAX_N = 50;

int N;
vector<pii> v1, v2;
int ans = INF;
int idx[MAX_N+1];
int chk[MAX_N+1];

int sum = 0;

void dfs(int x){
	if(x==N){
		ans = min(ans,sum); return;
	}
	for(int i=0; i<N; i++){
		if(chk[i]==0 && v1[x].second<=v2[i].second){
			chk[i]=1;
			if(v1[x].first!=v2[i].first){
				sum++;
			}
			dfs(x+1);
			chk[i] = 0;
			if(v1[x].first!=v2[i].first){
				sum--;
			}
		}else if(v1[x].second>v2[i].second){
			return;
		}
	}
}

int main(){
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		int a, b; scanf("%d%d", &a, &b);
		v1.push_back({a, b});
	}
	for(int i=0; i<N; i++){
		int a, b; scanf("%d%d", &a, &b);
		v2.push_back({a, b});
	}
	dfs(0);
	printf("%d", ans);
	return 0;
}

Compilation message

worst_reporter2.cpp: In function 'int main()':
worst_reporter2.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
worst_reporter2.cpp:43:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a, b; scanf("%d%d", &a, &b);
             ~~~~~^~~~~~~~~~~~~~~~
worst_reporter2.cpp:47:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a, b; scanf("%d%d", &a, &b);
             ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Execution timed out 2011 ms 384 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Execution timed out 2011 ms 384 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Execution timed out 2011 ms 384 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Execution timed out 2011 ms 384 KB Time limit exceeded
3 Halted 0 ms 0 KB -