답안 #131415

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
131415 2019-07-17T06:49:26 Z 임유진(#3181) Sparklers (JOI17_sparklers) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>

using namespace std;

#define MAXN 100005

typedef long long lint;

lint X[MAXN];

int main() {
	int N, K;
	lint T;

	scanf("%d%d%lld", &N, &K, &T);
	for(int i = 1; i <= N; i++) scanf("%lld", X + i);

	vector<lint> v1, v2;
	for(int i = 1; i < K; i++) v1.push_back(X[i + 1] - X[i]);
	for(int i = N; i > K; i--) v2.push_back(X[i] - X[i - 1]);

	lint S = 0ll;
	int cnt = 0;
	lint ti = 0ll;
	while(!v1.empty() || !v2.empty()) {
		if(v2.empty() || (!v1.empty() && v1.back() < v2.back())) {
			ti += v1.back();
			v1.pop_back();
		}
		else {
			ti += v2.back();
			v2.pop_back();
		}
		if(ti > 0) S = max(S, (ti - 1) / (++cnt * T * 2) + 1);
	}

	printf("%lld", S);
	return 0;
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%lld", &N, &K, &T);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:16:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i <= N; i++) scanf("%lld", X + i);
                              ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Incorrect 2 ms 256 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Incorrect 2 ms 256 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Incorrect 2 ms 256 KB Output isn't correct
8 Halted 0 ms 0 KB -