Submission #2875583
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef double D; typedef long long int LL; #define st first #define nd second #define pb push_back #define PLL pair <LL, LL> #define PII pair <int, int> const int N = 1e6 + 7; const int MX = 1e9 + 7; const LL INF = 1e18 + 9LL; int n; int tab[N]; int help[N]; int main(){ scanf("%d", &n); for(int i = 1; i <= n; ++i) scanf("%d", &tab[i]), help[i] = tab[i] - i; sort(help + 1, help + n + 1); int b = help[(n + 1) / 2]; LL res = 0LL; for(int i = 1; i <= n; ++i) res += abs(tab[i] - i - b); printf("%lld\n", res); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Linear Approximation |
User | Anadi |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 627 Byte |
Status | AC |
Exec Time | 37 ms |
Memory | 5120 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:23:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:26:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] help[i] = tab[i] - i; ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
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 | 2 ms | 2304 KB |
sample_02.txt | AC | 1 ms | 2304 KB |
sample_03.txt | AC | 1 ms | 2304 KB |
sample_04.txt | AC | 1 ms | 2304 KB |
subtask_1_01.txt | AC | 1 ms | 2304 KB |
subtask_1_02.txt | AC | 8 ms | 2432 KB |
subtask_1_03.txt | AC | 5 ms | 2432 KB |
subtask_1_04.txt | AC | 14 ms | 4736 KB |
subtask_1_05.txt | AC | 23 ms | 4992 KB |
subtask_1_06.txt | AC | 26 ms | 5120 KB |
subtask_1_07.txt | AC | 37 ms | 5120 KB |
subtask_1_08.txt | AC | 27 ms | 5120 KB |
subtask_1_09.txt | AC | 27 ms | 5120 KB |
subtask_1_10.txt | AC | 27 ms | 5120 KB |
subtask_1_11.txt | AC | 27 ms | 5120 KB |