답안 #1081124

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1081124 2024-08-29T18:37:23 Z Trent Semiexpress (JOI17_semiexpress) C++17
100 / 100
1 ms 460 KB
#include "bits/stdc++.h"
using namespace std;
#define forR(i, x) for(int i=0; i<(x); ++i)
#define REP(i, a, b) for(int i=(a); i<(b); ++i)
#define all(x) x.begin(), x.end()
#define boost() cin.sync_with_stdio(0); cin.tie(0)
typedef long long ll;
typedef vector<int> vi;

const int MK = 3010;
ll s[MK];
ll fe[MK];
ll a, b, c, t;
ll aCheck(ll fs) {
	// i >= 1: a * i + fs <= t -> i <= (t-fs) / a
	return (t-fs)/a;
}

struct interval{ int pe, ne; ll cp; };
ll amtNew(interval i) {
	ll aCan = s[i.ne] - i.cp;
	ll from = c * (i.cp - s[i.pe]) + fe[i.pe];
	// i >= 0: a * i + from <= t -> i <= (t-from)/a
	if(t >= from) return min(aCan, (t-from)/a + 1);
	return 0;
}
bool operator <(interval p, interval q) {
	return amtNew(p) < amtNew(q);
}

signed main() {
	boost();
	int n, m, k; cin >> n >> m >> k;
	cin >> a >> b >> c;
	cin >> t;
	REP(i, 1, m+1) {
		cin >> s[i];
		fe[i] = b * (s[i] - s[1]);
	}

	int cnt = k - m;
	ll tot = 0;
	REP(i, 2, m+1) if(fe[i] <= t) {
		++tot;
		// cerr << s[i] << '\n';
	}

	priority_queue<interval> ivl;
	REP(i, 1, m) {
		if(fe[i] <= t) {
			ll cr = aCheck(fe[i]);
			ll ain = s[i+1] - s[i] - 1;
			
			ll nCan = min(ain, cr);
			tot += nCan;
			// cerr << s[i] + 1 << ' ' << s[i] + nCan << '\n';

			if(s[i] + nCan + 1 < s[i+1]) {
				ivl.push({i, i+1, s[i] + nCan + 1});
			}
		}
	}

	forR(j, cnt) if(!ivl.empty()) {
		interval bes = ivl.top();
		ivl.pop();
		ll inc = amtNew(bes);
		if(inc > 0) {
			// cerr << bes.cp << ' ' << bes.cp + inc - 1 << '\n';
			tot += inc;
			if(bes.cp + inc < s[bes.ne]) {
				ivl.push({bes.pe, bes.ne, bes.cp + inc});
			}
		}
	}
	cout << tot << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 460 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 460 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct