Submission #854635

# Submission time Handle Problem Language Result Execution time Memory
854635 2023-09-28T08:59:12 Z AaW Semiexpress (JOI17_semiexpress) C++14
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define AI(x) begin(x),end(x)
#define endl '\n'
#ifdef DEBUG 
#define debug(args...) LKJ("\033[1;32m[ "+string(#args)+" ]\033[0m", args)
template<class I> void LKJ(I&&x){ cerr << x << '\n'; }
template<class I, class...T> void LKJ(I&&x, T&&...t){ cerr << x << ", ", LKJ(t...); }
template<class I> void OI(I a, I b){ while(a < b) cerr << *a << " \n"[next(a) == b], ++a; }
#else
#define debug(...) 0
#define OI(...) 0
#endif
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define pb push_back

signed main() {_
	ll n, m, k; 
	cin >> n >> m >> k;
	ll a, b, c;
	cin >> a >> b >> c;
	vector<ll> fast;

	ll t; 
	cin >> t;

	for (ll i = 0; i < m; ++i) {
		ll s; cin >> s;
		fast.pb(s);
	}

	priority_queue<ll> pq;
	ll used = 0;
	ll bptr = 0;
	ll ccur = 1;
	ll cnt = -1;
	ll cccc = 0;

	while (used < k - m && ccur <= n) {
		debug(ccur, cnt);
		if(bptr > m) break;
		int tleft = t - (b*(fast[bptr]-1) + c*(ccur-fast[bptr]));
		if (ccur == n) {
			debug("RRRR");
			if (tleft >= 0) cnt++;
			break;
		}
		if(tleft < 0) {
			if(ccur == fast[bptr]) {debug("LR"); break;}
			ccur = fast[bptr+1];
			bptr++;
			continue;
		}
		if (fast[bptr] == ccur) {
			int far = ccur + (tleft / a);
			far = min(n, far);
			if (far >= fast[bptr+1]) {
				cnt += fast[bptr+1] - fast[bptr];
				debug(fast[bptr], fast[bptr+1]-1);
				ccur = fast[bptr+1];
				bptr++;
			} else {
				cnt += far - ccur + 1;
				debug(ccur, far);
				ccur = far+1;
				if (ccur == fast[bptr+1]) bptr++;
			}
		} else {
			int far = ccur + (tleft / a);
			far = min(n, far);
			if (far >= fast[bptr+1]) {
				pq.push(fast[bptr+1] - ccur);
				debug(ccur, fast[bptr+1]-1 , "PQ", tleft);
				ccur = fast[bptr+1];
				bptr++;
			} else {
				pq.push(far - ccur + 1);
				debug(ccur, far, "PQ", tleft);
				ccur = far+1;
				if (ccur == fast[bptr+1]) bptr++;
				used++;
			}
		}
	}
	bptr++;
	while(bptr < n) {
		ccur = fast[bptr];
		int tleft = t - (b*(fast[bptr]-1) + c*(ccur-fast[bptr]));
		if (ccur == n) {
			debug("RRRR");
			if (tleft >= 0) cnt++;
			break;
		}
		if(tleft < 0) {
			if(ccur == fast[bptr]) {debug("LR"); break;}
			ccur = fast[bptr+1];
			bptr++;
			continue;
		}
		if (fast[bptr] == ccur) {
			int far = ccur + (tleft / a);
			far = min(n, far);
			if (far >= fast[bptr+1]) {
				cnt += fast[bptr+1] - fast[bptr];
				debug(fast[bptr], fast[bptr+1]-1);
				ccur = fast[bptr+1];
				bptr++;
			} else {
				cnt += far - ccur + 1;
				debug(ccur, far);
				ccur = far+1;
				if (ccur == fast[bptr+1]) bptr++;
			}
		} 
		bptr++;
	}
	debug(k-m, cnt);
	for (int i = 0; i < k - m; ++i) {
		if (pq.empty()) break;
		cnt += pq.top();
		pq.pop();
	}
	cout << cnt << endl;
}

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
semiexpress.cpp:43:3: note: in expansion of macro 'debug'
   43 |   debug(ccur, cnt);
      |   ^~~~~
semiexpress.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
semiexpress.cpp:47:4: note: in expansion of macro 'debug'
   47 |    debug("RRRR");
      |    ^~~~~
semiexpress.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
semiexpress.cpp:52:28: note: in expansion of macro 'debug'
   52 |    if(ccur == fast[bptr]) {debug("LR"); break;}
      |                            ^~~~~
semiexpress.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
semiexpress.cpp:62:5: note: in expansion of macro 'debug'
   62 |     debug(fast[bptr], fast[bptr+1]-1);
      |     ^~~~~
semiexpress.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
semiexpress.cpp:67:5: note: in expansion of macro 'debug'
   67 |     debug(ccur, far);
      |     ^~~~~
semiexpress.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
semiexpress.cpp:76:5: note: in expansion of macro 'debug'
   76 |     debug(ccur, fast[bptr+1]-1 , "PQ", tleft);
      |     ^~~~~
semiexpress.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
semiexpress.cpp:81:5: note: in expansion of macro 'debug'
   81 |     debug(ccur, far, "PQ", tleft);
      |     ^~~~~
semiexpress.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
semiexpress.cpp:93:4: note: in expansion of macro 'debug'
   93 |    debug("RRRR");
      |    ^~~~~
semiexpress.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
semiexpress.cpp:98:28: note: in expansion of macro 'debug'
   98 |    if(ccur == fast[bptr]) {debug("LR"); break;}
      |                            ^~~~~
semiexpress.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
semiexpress.cpp:108:5: note: in expansion of macro 'debug'
  108 |     debug(fast[bptr], fast[bptr+1]-1);
      |     ^~~~~
semiexpress.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
semiexpress.cpp:113:5: note: in expansion of macro 'debug'
  113 |     debug(ccur, far);
      |     ^~~~~
semiexpress.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
semiexpress.cpp:120:2: note: in expansion of macro 'debug'
  120 |  debug(k-m, cnt);
      |  ^~~~~
semiexpress.cpp:40:5: warning: unused variable 'cccc' [-Wunused-variable]
   40 |  ll cccc = 0;
      |     ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -