답안 #746898

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
746898 2023-05-23T08:20:56 Z vjudge1 Calvinball championship (CEOI15_teams) C++17
0 / 100
60 ms 508 KB
#include <bits/stdc++.h>
#include <array>
#define all(v) (v.begin()), (v.end())
#define setall(a, val) for(auto& x : a) x = val
#define ll long long
#define cerr (cerr << "D: ")
clock_t start_time;
using namespace std;
double get_time() { return (double)(clock() - start_time) / CLOCKS_PER_SEC; }
void init(bool oj = 1) {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	srand(time(0)); start_time = clock();
	if (oj) {
#ifndef ONLINE_JUDGE
		FILE* _ = freopen("in.txt", "r", stdin);
		//FILE* __ = freopen("out.txt", "w", stdout);
#endif
	}
}
const ll MOD = 1e9 + 7;
const ll N = 7e3 + 7;
const ll M = 2e3 + 7;
//####################################################################################

ll delivery(int N, int K, int L, vector<int> positions) {
	ll ans = 0;
	for (int i = N - 1; i >= 0; i -= K) {
		if (positions[max(0, i - K + 1)] > L / 2)
			ans += 2 * (L - positions[i - K + 1]);
		else if (positions[i] > L / 2)
			ans += L;
		else
			ans += 2 * positions[i];
		cerr << positions[i] << ", " << ans << endl;
	}
	return ans;
}

int main() {
	init(0);

	int n, k, l;
	cin >> n >> k >> l;
	vector<int> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	cout << delivery(n, k, l, v) << endl;

	cerr << get_time() << "s" << endl;
}

Compilation message

teams.cpp: In function 'void init(bool)':
teams.cpp:15:9: warning: unused variable '_' [-Wunused-variable]
   15 |   FILE* _ = freopen("in.txt", "r", stdin);
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 57 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 368 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 60 ms 508 KB Output isn't correct
2 Halted 0 ms 0 KB -