Submission #2850511
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define INF 1<<30 #define LINF 1ll<<60ll #define MOD 1000000007 #define pb(a) push_back(a) #define vi vector<int> #define vl vector<long long> #define vvi vector<vi> #define P pair<int,int> #define all(vec) (vec.begin()),(vec.end()) typedef long long ll; typedef unsigned long long ull; #define sz(x) ((int)(x).size()) #define in(x) int x;cin>>x #define bit(n) (1<<(n)) #define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define REPR(i, n) for(int i = n;i >= 0;--i) #define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i) #define FORVEC(i, v) for(int i = 0;i < sz(v);++i) template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;} template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;} #define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield) #define YES(n) cout<<((n)?"YES":"NO")<<endl #define Yes(n) cout<<((n)?"Yes":"No")<<endl #define yes(n) cout<<((n)?"yes":"no")<<endl #define possible(n) cout<<((n)?"possible":"impossible")<<endl #define Possible(n) cout<<((n)?"Possible":"Impossible")<<endl int main(){ int n; cin>>n; vi a(n); REP(i,n){ cin>>a[i]; } int normal=0; REP(i,n-1){ normal+=abs(a[i]-a[i+1]); } normal+=abs(a[0]); normal+=abs(a[n-1]); REP(i,n){ if(i==0)cout<<normal-abs(a[0])-abs(a[0]-a[1])+abs(a[1])<<endl; else if(i==n-1)cout<<normal-abs(a[n-1])-abs(a[n-1]-a[n-2])+abs(a[n-2])<<endl; else cout<<normal-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Traveling Plan |
User | ibuki2003 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1703 Byte |
Status | AC |
Exec Time | 187 ms |
Memory | 1664 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 | 183 ms | 1664 KB |
02.txt | AC | 183 ms | 1664 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 186 ms | 1664 KB |
05.txt | AC | 184 ms | 1664 KB |
06.txt | AC | 187 ms | 1664 KB |
07.txt | AC | 185 ms | 1664 KB |
08.txt | AC | 184 ms | 1664 KB |
09.txt | AC | 178 ms | 1280 KB |
10.txt | AC | 178 ms | 1280 KB |
11.txt | AC | 182 ms | 1280 KB |
12.txt | AC | 179 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 |