Submission #3188676
Source Code Expand
#include <iostream> #include <algorithm> #include <vector> #include <iomanip> #include <map> #include <queue> static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using namespace std; template<class T> constexpr T INF = ::numeric_limits<T>::max() / 2 - 170; int main() { int n; cin >> n; vector<int> v, v2{0}; v.emplace_back(0); for (int i = 0; i < n; ++i) { int k; cin >> k; v.emplace_back(k); } v.emplace_back(0); int sum = 0; for (int i = 0; i < n+1; ++i) { sum += abs(v[i+1]-v[i]); v2.emplace_back(sum); } for (int i = 1; i <= n; ++i) { cout << v2[i-1] + v2[n+1]-v2[i+1] + abs(v[i+1]-v[i-1]) << "\n"; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Traveling Plan |
User | firiexp |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 784 Byte |
Status | AC |
Exec Time | 38 ms |
Memory | 2168 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 | 38 ms | 2168 KB |
02.txt | AC | 38 ms | 2168 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 38 ms | 2168 KB |
05.txt | AC | 38 ms | 2168 KB |
06.txt | AC | 38 ms | 2168 KB |
07.txt | AC | 38 ms | 2168 KB |
08.txt | AC | 38 ms | 2168 KB |
09.txt | AC | 32 ms | 1784 KB |
10.txt | AC | 34 ms | 1784 KB |
11.txt | AC | 32 ms | 1784 KB |
12.txt | AC | 32 ms | 1784 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 |