Submission #715936

# Submission time Handle Problem Language Result Execution time Memory
715936 2023-03-28T13:54:23 Z vinnipuh01 Semiexpress (JOI17_semiexpress) C++17
18 / 100
1 ms 220 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 )
*/

int n, m, k, x, b, c, t, a[ 3002 ];
set <pair<int, int> > st;
vector <int> v;

main () {
	cin >> n >> m >> k;
	cin >> x >> b >> c;
	cin >> t;
	for ( int i = 1; i <= m; i ++ ) {
		cin >> a[ i ];
		if ( b * ( a[ i ] - 1 ) <= t )
			v.push_back( a[ i ] );
	}
	pos = 1;
	sum = 0;
	num = 0;
	v.push_back( n + 1 );
	while ( pos <= n ) {
		if ( sum > t )
			break;
		int next = pos + ( t - sum ) / x;
		if ( v[ num ] - 1 > next ) {
			st.insert( { v[ num ] - ( next + 1 ), next + 1 } );
			pos = v[ num ];
			sum = b * ( v[ num ] - 1 );
			num ++;
		}
		else {
			pos = v[ num ];
			sum = b * ( v[ num ] - 1 );
			num ++;
		}
	}
//	for ( auto i : st )
//		cout << i.first << " " << i.second << "\n";
	k -= m;
	while ( st.size() && k ) {
		pos = st.rbegin()->second;
		int tt = st.rbegin()->first;
		int l, r, mid;
		st.erase( --st.end() );
		k --;
		l = 0;
		r = v.size() - 1;
		while ( r > l ) {
			mid = ( l + r ) / 2;
			if ( v[ mid ] > pos )
				r = mid;
			else
				l = mid + 1;
		}
		l --;
		sum = ( pos - v[ l ] ) * c;
		sum += ( v[ l ] - 1 ) * b;
		if ( sum > t ) {
			ans += tt;
			k ++;
			continue;
		}
		int next = pos + ( t - sum ) / x;
		l = 0;
		r = v.size() - 1;
		while ( r > l ) {
			mid = ( l + r ) / 2;
			if ( v[ mid ] > pos )
				r = mid;
			else
				l = mid + 1;
		}
		num = l;
		if ( next >= v[ num ] - 1 )
			continue;
		st.insert( { v[ num ] - ( next + 1 ), next + 1 } );
	}
	ans += 1;
	for ( auto i : st ) {
		ans += i.first;
	}
	cout << n - ans;
}

Compilation message

semiexpress.cpp:51:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   51 | main () {
      | ^~~~
# 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 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 220 KB Output is correct
7 Correct 1 ms 216 KB Output is correct
8 Correct 1 ms 216 KB Output is correct
# 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 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 220 KB Output is correct
7 Correct 1 ms 216 KB Output is correct
8 Correct 1 ms 216 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Incorrect 0 ms 212 KB Output isn't correct
15 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 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 220 KB Output is correct
7 Correct 1 ms 216 KB Output is correct
8 Correct 1 ms 216 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Incorrect 0 ms 212 KB Output isn't correct
15 Halted 0 ms 0 KB -