Submission #329872

# Submission time Handle Problem Language Result Execution time Memory
329872 2020-11-23T00:59:18 Z arnold518 None (JOI16_worst_reporter2) C++14
0 / 100
8 ms 9708 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++) printf("%d ", A[i]); printf("\n");
	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:27:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   27 |  for(int i=1; i<=N; i++) printf("%d ", A[i]); printf("\n");
      |  ^~~
worst_reporter2.cpp:27:47: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   27 |  for(int i=1; i<=N; i++) printf("%d ", A[i]); printf("\n");
      |                                               ^~~~~~
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 Incorrect 8 ms 9708 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 9708 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 9708 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 9708 KB Output isn't correct
2 Halted 0 ms 0 KB -