답안 #142653

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
142653 2019-08-10T09:30:34 Z arnold518 Semiexpress (JOI17_semiexpress) C++14
100 / 100
23 ms 2540 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e9;
const int MAXK = 3000;
const int MAXM = 3000;

int N, M, K, S[MAXM+10];
ll A, B, C, T, ans;

int main()
{
	int i, j;
	
	scanf("%d%d%d%lld%lld%lld%lld", &N, &M, &K, &A, &B, &C, &T);
	for(i=0; i<M; i++) scanf("%d", &S[i]); S[M]=N+1;
	K-=M;
	vector<int> todo;
	for(i=0; i<M; i++)
	{
		int pt=S[i];
		for(j=0; j<=K && pt<S[i+1]; j++)
		{
			if(T<B*(S[i]-1)+C*(pt-S[i])) break;
			int nxt=(T-B*(S[i]-1)-C*(pt-S[i]))/A+pt;
			if(j!=0)
			{
				if(nxt<S[i+1]) todo.push_back(nxt-pt+1), pt=nxt+1;
				else { todo.push_back(S[i+1]-pt); break; }
			}
			else
			{
				if(nxt<S[i+1]) ans+=nxt-pt+1, pt=nxt+1;
				else { ans+=S[i+1]-pt; break; }
			}
		}
	}
	sort(todo.begin(), todo.end(), greater<int>());
	for(i=0; i<todo.size() && i<K; i++) ans+=todo[i];
	printf("%d", ans-1);
}

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:20:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(i=0; i<M; i++) scanf("%d", &S[i]); S[M]=N+1;
  ^~~
semiexpress.cpp:20:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(i=0; i<M; i++) scanf("%d", &S[i]); S[M]=N+1;
                                         ^
semiexpress.cpp:43:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0; i<todo.size() && i<K; i++) ans+=todo[i];
           ~^~~~~~~~~~~~
semiexpress.cpp:44:20: warning: format '%d' expects argument of type 'int', but argument 2 has type 'll {aka long long int}' [-Wformat=]
  printf("%d", ans-1);
               ~~~~~^
semiexpress.cpp:19:7: 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);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:20:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=0; i<M; i++) scanf("%d", &S[i]); S[M]=N+1;
                     ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 424 KB Output is correct
19 Correct 3 ms 504 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 380 KB Output is correct
22 Correct 4 ms 504 KB Output is correct
23 Correct 23 ms 2536 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 16 ms 2540 KB Output is correct
30 Correct 10 ms 1520 KB Output is correct