Submission #4040495
Source Code Expand
#include <bits/stdc++.h> using namespace std; /////////////////////////////////////////// const long long int INF = INT32_MAX; const long long int Mod = 1000000007; const long long int mod = 100000;//10^5 using ll = long long int; //long long int は64bit using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using pii = pair<int,int>; #define pb(x) push_back(x) #define mp(x,y) make_pair(x,y) #define mt make_tuple #define all(x) (x).begin(),(x).end() #define rep(i,N) for(int i=0;i<N;i++) #define np nullptr template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; } template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; } template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根; #define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート #define fill(x,num) memset(x,num,sizeof(x)); typedef vector<vector<ll> > matrix; // cin.tie(0);ios::sync_with_stdio(false); void cinit(){cin.tie(0);ios::sync_with_stdio(false);} //////////////////////////^^ *Emile ^^^////////////////////////////////////////////////////// ll n; Vi v; int main(){ cinit();cin>>n; ll aa; rep(i,n){cin>>aa;v.pb(aa);} Vi v2(v.size()); copy(all(v),v2.begin());sort(all(v2)); Vi v3;v3.pb(0); copy(all(v),std::back_inserter(v3));v3.pb(0); ll sum=0; for(int i = 1;i<=n+1;i++){ sum+=abs(v3[i-1]-v3[i]); } for(int i=1;i<=n;i++){ cout<<sum-abs(v3[i]-v3[i-1])-abs(v3[i+1]-v3[i])+abs(v3[i+1]-v3[i-1])<<endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Traveling Plan |
User | emile11235 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1642 Byte |
Status | AC |
Exec Time | 168 ms |
Memory | 3700 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 | 165 ms | 3700 KB |
02.txt | AC | 165 ms | 3700 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 167 ms | 3700 KB |
05.txt | AC | 165 ms | 3700 KB |
06.txt | AC | 168 ms | 3700 KB |
07.txt | AC | 166 ms | 3700 KB |
08.txt | AC | 166 ms | 3700 KB |
09.txt | AC | 166 ms | 3444 KB |
10.txt | AC | 162 ms | 3444 KB |
11.txt | AC | 161 ms | 3444 KB |
12.txt | AC | 163 ms | 3444 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 |