답안 #65169

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
65169 2018-08-06T23:08:22 Z keko37 Semiexpress (JOI17_semiexpress) C++14
100 / 100
6 ms 1540 KB
#include<iostream>
#include<queue>

using namespace std;

typedef long long llint;

const int MAXN = 3005;

llint n, m, k, t, a, b, c, lim, sol;
llint s[MAXN], d[MAXN];
priority_queue < pair <llint, int> > pq;

llint val (int ind) {
	llint ost = (t - (s[ind]-1)*b - (s[ind+1]-s[ind]-1 - d[ind])*c);
	if (ost < c) return 0; return min(d[ind], 1 + (ost - c)/a);
}

int main () {
	cin >> n >> m >> k >> a >> b >> c >> t;
	for (int i=1; i<=m; i++) {
		cin >> s[i];
	}
	for (int i=m; i>=1; i--) {
		if (t >= (s[i]-1) * b) {
			lim = i;
			break;
		}
	}
	for (int i=1; i<=min(lim, m-1); i++) {
		d[i] = max(0LL, (s[i+1]-s[i]-1) - (t-(s[i]-1)*b) / a);
		pq.push(make_pair(val(i), i));
	}
	for (int i=0; i<k-m; i++) {
		llint v = pq.top().first;
		int ind = pq.top().second;
		pq.pop();
		d[ind] -= v;
		pq.push(make_pair(val(ind), ind));
	}
	for (int i=1; i<=min(lim, m-1); i++) {
		sol += s[i+1] - s[i] - d[i];
	}
	cout << sol + (lim == m) - 1;
	return 0;
}

Compilation message

semiexpress.cpp: In function 'llint val(int)':
semiexpress.cpp:16:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if (ost < c) return 0; return min(d[ind], 1 + (ost - c)/a);
  ^~
semiexpress.cpp:16:25: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  if (ost < c) return 0; return min(d[ind], 1 + (ost - c)/a);
                         ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 3 ms 480 KB Output is correct
3 Correct 5 ms 592 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 3 ms 480 KB Output is correct
3 Correct 5 ms 592 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 656 KB Output is correct
10 Correct 2 ms 660 KB Output is correct
11 Correct 3 ms 664 KB Output is correct
12 Correct 3 ms 900 KB Output is correct
13 Correct 4 ms 900 KB Output is correct
14 Correct 2 ms 900 KB Output is correct
15 Correct 2 ms 900 KB Output is correct
16 Correct 2 ms 900 KB Output is correct
17 Correct 2 ms 924 KB Output is correct
18 Correct 3 ms 924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 3 ms 480 KB Output is correct
3 Correct 5 ms 592 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 656 KB Output is correct
10 Correct 2 ms 660 KB Output is correct
11 Correct 3 ms 664 KB Output is correct
12 Correct 3 ms 900 KB Output is correct
13 Correct 4 ms 900 KB Output is correct
14 Correct 2 ms 900 KB Output is correct
15 Correct 2 ms 900 KB Output is correct
16 Correct 2 ms 900 KB Output is correct
17 Correct 2 ms 924 KB Output is correct
18 Correct 3 ms 924 KB Output is correct
19 Correct 5 ms 1052 KB Output is correct
20 Correct 4 ms 1068 KB Output is correct
21 Correct 4 ms 1104 KB Output is correct
22 Correct 5 ms 1132 KB Output is correct
23 Correct 3 ms 1244 KB Output is correct
24 Correct 3 ms 1280 KB Output is correct
25 Correct 3 ms 1280 KB Output is correct
26 Correct 6 ms 1280 KB Output is correct
27 Correct 4 ms 1280 KB Output is correct
28 Correct 6 ms 1540 KB Output is correct
29 Correct 3 ms 1540 KB Output is correct
30 Correct 4 ms 1540 KB Output is correct