Submission #2765924


Source Code Expand

Copy
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
#define fcout cout<<fixed<<setprecision(10)
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;

int main(){
	int n; cin>>n;
	int a[200000];
	FOR(i,0,n){
		cin>>a[i];
		a[i]-=i;
	}
	sort(a,a+n);
	int b=a[n/2];
	ll ans=0;
	FOR(i,0,n){
		ans+=abs(a[i]-b);
	}
	co(ans);
}

Submission Info

Submission Time
Task C - Linear Approximation
User dama_math
Language C++14 (GCC 5.4.1)
Score 300
Code Size 791 Byte
Status AC
Exec Time 119 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 19
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 AC 22 ms 384 KB
subtask_1_03.txt AC 19 ms 384 KB
subtask_1_04.txt AC 53 ms 640 KB
subtask_1_05.txt AC 95 ms 896 KB
subtask_1_06.txt AC 105 ms 1024 KB
subtask_1_07.txt AC 119 ms 1024 KB
subtask_1_08.txt AC 107 ms 1024 KB
subtask_1_09.txt AC 109 ms 1024 KB
subtask_1_10.txt AC 108 ms 1024 KB
subtask_1_11.txt AC 110 ms 1024 KB