Submission #3403310
Source Code Expand
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<iomanip> #include<math.h> #include<complex> #include<queue> #include<deque> #include<stack> #include<map> #include<set> #include<bitset> using namespace std; #define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i ) #define rep(i,n) REP(i,0,n) typedef long long ll; typedef pair<int,int> pint; typedef pair<ll,int> pli; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; using namespace std; int main(){ ll n; cin >> n; ll a[n+1]; ll pos=0; ll ans=inf; rep(i,n)cin >> a[i]; a[n]=0; ll score=0; rep(i,n/2){ score+=abs(a[2*i]-a[2*i+2]); } if(n%2==0)score+=a[n-1]; ans=min(ans,score); if(n%2==0){ score=abs(a[0]-a[1]); rep(i,n/2-1){ score+=abs(a[2*i+1]-a[2*i+3]); } } ans=min(ans,score); cout << ans << endl; return 0;}
Submission Info
Submission Time | |
---|---|
Task | C - 柱柱柱柱柱 |
User | hnakashima |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1011 Byte |
Status | WA |
Exec Time | 25 ms |
Memory | 1024 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | sample_01.txt, sample_02.txt, sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | WA | 1 ms | 256 KB |
sample_02.txt | AC | 1 ms | 256 KB |
sample_03.txt | WA | 1 ms | 256 KB |
subtask1_01.txt | AC | 1 ms | 256 KB |
subtask1_02.txt | AC | 1 ms | 256 KB |
subtask1_03.txt | AC | 1 ms | 256 KB |
subtask1_04.txt | WA | 25 ms | 1024 KB |
subtask1_05.txt | WA | 25 ms | 1024 KB |
subtask1_06.txt | WA | 25 ms | 1024 KB |
subtask1_07.txt | WA | 25 ms | 1024 KB |