Submission #659398

# Submission time Handle Problem Language Result Execution time Memory
659398 2022-11-17T15:35:38 Z vinnipuh01 Exhibition (JOI19_ho_t2) C++17
0 / 100
1 ms 212 KB
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>
#define int long long
#define sqrt sqrtl

using namespace std;

const long long oo = 1000000000000000000;

long long sum, ans = 0, mx = 0, mn = 1000000000, num, pos;


/*
    ViHHiPuh

   (( `'-""``""-'` ))
     )-__-_.._-__-(
   / --- (o _ o) --- \
   \ .-* ( .0. ) *-. /
   _'-. ,_ '=' _, .-'_
  / `;#'#'# - #'#'#;` \
 \_)) -----'#'----- ((_/
      # --------- #
  '# ------- ------ #'
  /..-'# ------- #'-.\
  _\...-\'# -- #'/-.../_
  ((____)- '#' -(____))


    cout << fixed << setprecision(6) << x;

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    freopen ( "sum.in", "r", stdin )
*/

vector <pair<int, int> > v;
vector <int> vv;
map <int, int> mp;

int a[ 100001 ], x, y, dp[ 100001 ], p[ 100001 ], d[ 100001 ], pr[ 100001 ], n, m;
pair<int, int> t[ 400001 ], an;


int fin( int x ) {
	int l = 0, r = m, mid;
	if ( a[ m ] < x )
		return -1;
	while ( r > l ) {
		mid = ( r + l ) / 2;
		if ( a[ mid ] >= x ) {
			r = mid;
		}
		else
			l = mid + 1;
	}
	return l;
}

pair<int, int> add( pair<int, int> a, pair<int, int> b ) {
	if ( a.first > b.first )
		return a;
	else if ( b.first > a.first )
		return b;
	if ( a.second < b.second )
		return a;
	else
		return b;
}

void upd( int v, int tl, int tr, int pos ) {
	if ( tl > pos || tr < pos )
		return;
	if ( tl == tr ) {
		t[ v ] = add( an, t[ v ] );
		return;
	}
	int mid = ( tl + tr ) / 2;
	upd( v + v, tl, mid, pos );
	upd( v + v + 1, mid + 1, tr, pos );
	t[ v ] = add( t[ v + v ], t[ v + v + 1 ] );
}

void gett( int v, int tl, int tr, int l, int r ) {
	if ( tl > r || tr < l )
		return;
	if ( tl >= l && tr <= r ) {
//		cout << v << " - " << t[ v ].first << " " << t[ v ].second << "---\n";
		an = add( an, t[ v ] );
		return;
	}
	int mid = ( tl + tr ) / 2;
	gett( v + v, tl, mid, l, r );
	gett( v + v + 1, mid + 1, tr, l, r );
}

bool cmp( pair<int, int> a, pair<int, int> b ) {
	if ( a.second != b.second )
		return a.second < b.second;
	return a.first < b.first;
}

main () {
	cin >> n;
	cin >> m;
	for ( int i = 1; i <= n; i ++ ) {
		cin >> x >> y;
		v.push_back( { x, y } );
		vv.push_back( y );
	}
	sort( vv.begin(), vv.end() );
	for ( int i = 0; i < vv.size(); i ++ ) {
		if ( !mp[ vv[ i ] ] )
			mp[ vv[ i ] ] = ++num;
	}
	for ( int i = 0; i < v.size(); i ++ ) {
		v[ i ].second = mp[ v[ i ].second ];
	}
	sort( v.begin(), v.end(), cmp );
	for ( int i = 1; i <= m; i ++ )
		cin >> a[ i ];
	sort( a + 1, a + m + 1 );
	for ( int i = 0; i < v.size(); i ++ ) {
		an.first = 0;
		num = fin( v[ i ].first );
		if ( num == -1 )
			continue;
		an.second = 0;
		gett( 1, 1, n, 1, v[ i ].second );
		if ( an.first != 0 ) {
			if ( an.second != m ) {
				an.first ++;
				an.second = max( num, an.second + 1 );
			}
		}
		else {
			an.first = 1;
			an.second = num;
		}
//		cout << v[ i ].first << " " << v[ i ].second << " - " << an.first << " " << an.second << "\n";
		upd( 1, 1, n, v[ i ].second );
		ans = max( ans, an.first );
	}
	cout << ans;
}

Compilation message

joi2019_ho_t2.cpp:113:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  113 | main () {
      | ^~~~
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:122:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  122 |  for ( int i = 0; i < vv.size(); i ++ ) {
      |                   ~~^~~~~~~~~~~
joi2019_ho_t2.cpp:126:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  126 |  for ( int i = 0; i < v.size(); i ++ ) {
      |                   ~~^~~~~~~~~~
joi2019_ho_t2.cpp:133:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  133 |  for ( int i = 0; i < v.size(); i ++ ) {
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -