Submission #2765496


Source Code Expand

Copy
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a.begin(), a.end());
	int x = a[n / 2];
	int ret = 0;
	for (int i = 0; i < n; ++i) {
		ret += (a[i] > x ? a[i] - x : x - a[i]);
	}
	cout << ret << '\n';
	return 0;
}

Submission Info

Submission Time
Task C - Linear Approximation
User square1001
Language C++14 (GCC 5.4.1)
Score 0
Code Size 438 Byte
Status WA
Exec Time 34 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 4
AC × 11
WA × 8
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
sample_04.txt AC 1 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt WA 7 ms 384 KB
subtask_1_03.txt WA 5 ms 384 KB
subtask_1_04.txt WA 13 ms 640 KB
subtask_1_05.txt WA 20 ms 896 KB
subtask_1_06.txt AC 23 ms 1024 KB
subtask_1_07.txt WA 34 ms 1024 KB
subtask_1_08.txt WA 24 ms 1024 KB
subtask_1_09.txt WA 23 ms 1024 KB
subtask_1_10.txt WA 23 ms 1024 KB
subtask_1_11.txt AC 24 ms 1024 KB