Submission #329873

# Submission time Handle Problem Language Result Execution time Memory
329873 2020-11-23T00:59:31 Z arnold518 None (JOI16_worst_reporter2) C++14
60 / 100
2000 ms 25564 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 4e5;

int N;
pii _A[MAXN+10];
int A[MAXN+10];

int B[MAXN+10];
vector<int> V[MAXN+10];

int main()
{
	scanf("%d", &N);
	for(int i=1; i<=N; i++) scanf("%d%d", &_A[i].second, &_A[i].first), _A[i].second*=-1;
	for(int i=1; i<=N; i++) scanf("%d%d", &_A[i+N].second, &_A[i+N].first);

	N*=2;
	sort(_A+1, _A+N+1);
	for(int i=1; i<=N; i++) A[i]=_A[i].second;
	for(int i=1; i<=N; i++)
	{
		if(A[i]<0) B[i]=B[i-1]+1;
		else B[i]=B[i-1]-1;
	}

	int ans=N/2;
	for(int i=1; i<=N; i++)
	{	
		if(A[i]<0)
		{
			V[-A[i]].push_back(i);
		}
		else
		{
			if(V[A[i]].empty()) continue;
			bool flag=true;
			for(int j=V[A[i]].back(); j<i; j++)
			{
				if(B[j]<1) flag=false;
			}

			if(!flag)
			{
				V[A[i]].clear();
			}
			else
			{
				for(int j=V[A[i]].back(); j<i; j++)
				{
					B[j]--;
				}
				V[A[i]].pop_back();
				ans--;
			}
		}
	}
	printf("%d\n", ans);
}

Compilation message

worst_reporter2.cpp: In function 'int main()':
worst_reporter2.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
worst_reporter2.cpp:20:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |  for(int i=1; i<=N; i++) scanf("%d%d", &_A[i].second, &_A[i].first), _A[i].second*=-1;
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
worst_reporter2.cpp:21:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |  for(int i=1; i<=N; i++) scanf("%d%d", &_A[i+N].second, &_A[i+N].first);
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9708 KB Output is correct
2 Correct 7 ms 9708 KB Output is correct
3 Correct 7 ms 9708 KB Output is correct
4 Correct 7 ms 9708 KB Output is correct
5 Correct 7 ms 9708 KB Output is correct
6 Correct 7 ms 9708 KB Output is correct
7 Correct 7 ms 9708 KB Output is correct
8 Correct 7 ms 9708 KB Output is correct
9 Correct 7 ms 9708 KB Output is correct
10 Correct 7 ms 9708 KB Output is correct
11 Correct 8 ms 9708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9708 KB Output is correct
2 Correct 7 ms 9708 KB Output is correct
3 Correct 7 ms 9708 KB Output is correct
4 Correct 7 ms 9708 KB Output is correct
5 Correct 7 ms 9708 KB Output is correct
6 Correct 7 ms 9708 KB Output is correct
7 Correct 7 ms 9708 KB Output is correct
8 Correct 7 ms 9708 KB Output is correct
9 Correct 7 ms 9708 KB Output is correct
10 Correct 7 ms 9708 KB Output is correct
11 Correct 8 ms 9708 KB Output is correct
12 Correct 7 ms 9708 KB Output is correct
13 Correct 7 ms 9708 KB Output is correct
14 Correct 7 ms 9708 KB Output is correct
15 Correct 7 ms 9708 KB Output is correct
16 Correct 8 ms 9708 KB Output is correct
17 Correct 7 ms 9708 KB Output is correct
18 Correct 7 ms 9708 KB Output is correct
19 Correct 7 ms 9708 KB Output is correct
20 Correct 7 ms 9708 KB Output is correct
21 Correct 7 ms 9708 KB Output is correct
22 Correct 7 ms 9708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9708 KB Output is correct
2 Correct 7 ms 9708 KB Output is correct
3 Correct 7 ms 9708 KB Output is correct
4 Correct 7 ms 9708 KB Output is correct
5 Correct 7 ms 9708 KB Output is correct
6 Correct 7 ms 9708 KB Output is correct
7 Correct 7 ms 9708 KB Output is correct
8 Correct 7 ms 9708 KB Output is correct
9 Correct 7 ms 9708 KB Output is correct
10 Correct 7 ms 9708 KB Output is correct
11 Correct 8 ms 9708 KB Output is correct
12 Correct 7 ms 9708 KB Output is correct
13 Correct 7 ms 9708 KB Output is correct
14 Correct 7 ms 9708 KB Output is correct
15 Correct 7 ms 9708 KB Output is correct
16 Correct 8 ms 9708 KB Output is correct
17 Correct 7 ms 9708 KB Output is correct
18 Correct 7 ms 9708 KB Output is correct
19 Correct 7 ms 9708 KB Output is correct
20 Correct 7 ms 9708 KB Output is correct
21 Correct 7 ms 9708 KB Output is correct
22 Correct 7 ms 9708 KB Output is correct
23 Correct 14 ms 10220 KB Output is correct
24 Correct 13 ms 10092 KB Output is correct
25 Correct 16 ms 10092 KB Output is correct
26 Correct 13 ms 10092 KB Output is correct
27 Correct 20 ms 10092 KB Output is correct
28 Correct 11 ms 9964 KB Output is correct
29 Correct 11 ms 9964 KB Output is correct
30 Correct 10 ms 9964 KB Output is correct
31 Correct 10 ms 9964 KB Output is correct
32 Correct 30 ms 9964 KB Output is correct
33 Correct 11 ms 9964 KB Output is correct
34 Correct 11 ms 9964 KB Output is correct
35 Correct 10 ms 9964 KB Output is correct
36 Correct 10 ms 9964 KB Output is correct
37 Correct 32 ms 9964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9708 KB Output is correct
2 Correct 7 ms 9708 KB Output is correct
3 Correct 7 ms 9708 KB Output is correct
4 Correct 7 ms 9708 KB Output is correct
5 Correct 7 ms 9708 KB Output is correct
6 Correct 7 ms 9708 KB Output is correct
7 Correct 7 ms 9708 KB Output is correct
8 Correct 7 ms 9708 KB Output is correct
9 Correct 7 ms 9708 KB Output is correct
10 Correct 7 ms 9708 KB Output is correct
11 Correct 8 ms 9708 KB Output is correct
12 Correct 7 ms 9708 KB Output is correct
13 Correct 7 ms 9708 KB Output is correct
14 Correct 7 ms 9708 KB Output is correct
15 Correct 7 ms 9708 KB Output is correct
16 Correct 8 ms 9708 KB Output is correct
17 Correct 7 ms 9708 KB Output is correct
18 Correct 7 ms 9708 KB Output is correct
19 Correct 7 ms 9708 KB Output is correct
20 Correct 7 ms 9708 KB Output is correct
21 Correct 7 ms 9708 KB Output is correct
22 Correct 7 ms 9708 KB Output is correct
23 Correct 14 ms 10220 KB Output is correct
24 Correct 13 ms 10092 KB Output is correct
25 Correct 16 ms 10092 KB Output is correct
26 Correct 13 ms 10092 KB Output is correct
27 Correct 20 ms 10092 KB Output is correct
28 Correct 11 ms 9964 KB Output is correct
29 Correct 11 ms 9964 KB Output is correct
30 Correct 10 ms 9964 KB Output is correct
31 Correct 10 ms 9964 KB Output is correct
32 Correct 30 ms 9964 KB Output is correct
33 Correct 11 ms 9964 KB Output is correct
34 Correct 11 ms 9964 KB Output is correct
35 Correct 10 ms 9964 KB Output is correct
36 Correct 10 ms 9964 KB Output is correct
37 Correct 32 ms 9964 KB Output is correct
38 Execution timed out 2076 ms 25564 KB Time limit exceeded
39 Halted 0 ms 0 KB -