답안 #20965

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20965 2017-03-23T05:59:12 Z kdh9949 Semiexpress (JOI17_semiexpress) C++14
100 / 100
16 ms 7172 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, m, k, cnt[3010];
ll A, B, C, T, a[3010], ans;
vector<ll> c[3010];

ll get(int x, int y){ return (y < c[x].size()) ? c[x][y] : 0; }

int main(){
	scanf("%d%d%d%lld%lld%lld%lld", &n, &m, &k, &A, &B, &C, &T); n--;
	for(int i = 1; i <= m; i++){ scanf("%lld", a + i); a[i]--; }
	a[m + 1] = n + 1;
	for(int i = 1; i <= m; i++){
		ll t = T - B * a[i];
		ll p = a[i];
		while(t >= 0 && p < a[i + 1] && c[i].size() <= k - m){
			c[i].push_back(min(a[i + 1] - p, (t / A) + 1));
			p += ((t / A) + 1);
			t -= ((t / A) + 1) * C;
		}
	}
	for(int i = 1; i <= m; i++) ans += get(i, 0);
	fill(cnt + 1, cnt + m + 1, 1);
	for(int i = 0; i < k - m; i++){
		ll mx = get(1, cnt[1]), mi = 1;
		for(int j = 2; j <= m; j++){
			if(mx < get(j, cnt[j])){
				mx = get(j, cnt[j]);
				mi = j;
			}
		}
		ans += mx;
		cnt[mi]++;
	}
	printf("%lld\n", ans - 1);
}

Compilation message

semiexpress.cpp: In function 'll get(int, int)':
semiexpress.cpp:9:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 ll get(int x, int y){ return (y < c[x].size()) ? c[x][y] : 0; }
                                 ^
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:18:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(t >= 0 && p < a[i + 1] && c[i].size() <= k - m){
                                               ^
semiexpress.cpp:12:61: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%lld%lld%lld%lld", &n, &m, &k, &A, &B, &C, &T); n--;
                                                             ^
semiexpress.cpp:13:51: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i <= m; i++){ scanf("%lld", a + i); a[i]--; }
                                                   ^

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2124 KB Output is correct
2 Correct 0 ms 2124 KB Output is correct
3 Correct 0 ms 2124 KB Output is correct
4 Correct 0 ms 2124 KB Output is correct
5 Correct 0 ms 2124 KB Output is correct
6 Correct 0 ms 2124 KB Output is correct
7 Correct 0 ms 2124 KB Output is correct
8 Correct 0 ms 2124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2124 KB Output is correct
2 Correct 0 ms 2124 KB Output is correct
3 Correct 0 ms 2124 KB Output is correct
4 Correct 0 ms 2124 KB Output is correct
5 Correct 0 ms 2124 KB Output is correct
6 Correct 0 ms 2124 KB Output is correct
7 Correct 0 ms 2124 KB Output is correct
8 Correct 0 ms 2124 KB Output is correct
9 Correct 0 ms 2124 KB Output is correct
10 Correct 0 ms 2124 KB Output is correct
11 Correct 0 ms 2124 KB Output is correct
12 Correct 0 ms 2124 KB Output is correct
13 Correct 0 ms 2124 KB Output is correct
14 Correct 0 ms 2124 KB Output is correct
15 Correct 0 ms 2124 KB Output is correct
16 Correct 0 ms 2124 KB Output is correct
17 Correct 0 ms 2124 KB Output is correct
18 Correct 0 ms 2124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2124 KB Output is correct
2 Correct 0 ms 2124 KB Output is correct
3 Correct 0 ms 2124 KB Output is correct
4 Correct 0 ms 2124 KB Output is correct
5 Correct 0 ms 2124 KB Output is correct
6 Correct 0 ms 2124 KB Output is correct
7 Correct 0 ms 2124 KB Output is correct
8 Correct 0 ms 2124 KB Output is correct
9 Correct 0 ms 2124 KB Output is correct
10 Correct 0 ms 2124 KB Output is correct
11 Correct 0 ms 2124 KB Output is correct
12 Correct 0 ms 2124 KB Output is correct
13 Correct 0 ms 2124 KB Output is correct
14 Correct 0 ms 2124 KB Output is correct
15 Correct 0 ms 2124 KB Output is correct
16 Correct 0 ms 2124 KB Output is correct
17 Correct 0 ms 2124 KB Output is correct
18 Correct 0 ms 2124 KB Output is correct
19 Correct 0 ms 2124 KB Output is correct
20 Correct 3 ms 2124 KB Output is correct
21 Correct 0 ms 2124 KB Output is correct
22 Correct 0 ms 2256 KB Output is correct
23 Correct 16 ms 7172 KB Output is correct
24 Correct 0 ms 2256 KB Output is correct
25 Correct 0 ms 2124 KB Output is correct
26 Correct 0 ms 2256 KB Output is correct
27 Correct 0 ms 2256 KB Output is correct
28 Correct 0 ms 2256 KB Output is correct
29 Correct 16 ms 6036 KB Output is correct
30 Correct 6 ms 3696 KB Output is correct