Submission #2255777


Source Code Expand

/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-3-25 21:00:57
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  int N;
  cin >> N;
  int A[100010];
  A[0] = 0;
  for (auto i = 1; i <= N; i++)
  {
    cin >> A[i];
  }
  A[N + 1] = 0;
  int ans = 0;
  for (auto i = 0; i <= N; i++)
  {
    ans += abs(A[i] - A[i + 1]);
  }
  for (auto i = 1; i <= N; i++)
  {
    cout << ans - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1]) << endl;
  }
}

Submission Info

Submission Time
Task C - Traveling Plan
User kazunetakahashi
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1276 Byte
Status AC
Exec Time 185 ms
Memory 1664 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
01.txt AC 183 ms 1664 KB
02.txt AC 185 ms 1664 KB
03.txt AC 1 ms 256 KB
04.txt AC 182 ms 1664 KB
05.txt AC 184 ms 1664 KB
06.txt AC 184 ms 1664 KB
07.txt AC 184 ms 1664 KB
08.txt AC 182 ms 1664 KB
09.txt AC 174 ms 1280 KB
10.txt AC 176 ms 1280 KB
11.txt AC 176 ms 1280 KB
12.txt AC 178 ms 1280 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 1 ms 256 KB
sample-03.txt AC 1 ms 256 KB