Submission #2404613
Source Code Expand
#include <bits/stdc++.h> using namespace std; using LL = long long; using P = pair<int, int>; using Tapris = tuple<int, int, int>; #define REP(i, n) for(LL i = 0; i < n; ++i) #define FOR(i, a, n) for(LL i = a; i < n; ++i) #define pb(a) push_back(a) #define all(x) (x).begin(),(x).end() const int INF = (int)1e9; const LL INFL = (LL)1e15; const int MOD = 1e9 + 7; int dy[]={0, 0, 1, -1, 0}; int dx[]={1, -1, 0, 0, 0}; //#define int long long /*************** using variables ***************/ int n; vector<int> a; vector<int> charge; // charge[N] := NからN+1に行くのにかかる金額 int sum = 0; /**********************************************/ signed main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> n; a.assign(n+2, 0); charge.assign(n+2, 0); FOR(i, 1, n+1) cin >> a[i]; REP(i, n+1){ charge[i] = abs(a[i] - a[i+1]); sum += charge[i]; } FOR(i, 0, n){ cout << sum - charge[i] - charge[i+1] + abs(a[i] - a[i+2]) << endl; } }
Submission Info
Submission Time | |
---|---|
Task | C - Traveling Plan |
User | wheson |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1058 Byte |
Status | AC |
Exec Time | 158 ms |
Memory | 2048 KB |
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 |
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 | 155 ms | 2048 KB |
02.txt | AC | 157 ms | 2048 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 158 ms | 2048 KB |
05.txt | AC | 156 ms | 2048 KB |
06.txt | AC | 155 ms | 2048 KB |
07.txt | AC | 157 ms | 2048 KB |
08.txt | AC | 156 ms | 2048 KB |
09.txt | AC | 155 ms | 1664 KB |
10.txt | AC | 157 ms | 1792 KB |
11.txt | AC | 156 ms | 1792 KB |
12.txt | AC | 157 ms | 1792 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 |