Submission #1793487


Source Code Expand

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,0,n){
        cin >> a[i];
    }
    
    vector<int> b(n);
    
    REP(i,1,n){
        b[i] = b[i] - b[i-1];
    }
    
    int cnt = 0;
    for(int i = 1; i < n; i++){
        if(1LL * b[i] * b[i-1] < 0){
            cnt++;
            i++;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}

Submission Info

Submission Time
Task A - Sorted Arrays
User homesentinel
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1794 Byte
Status WA
Exec Time 42 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
WA × 3
WA × 17
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt
Case Name Status Exec Time Memory
sample_01.txt WA 1 ms 256 KB
sample_02.txt WA 1 ms 256 KB
sample_03.txt WA 1 ms 256 KB
subtask_1_01.txt WA 25 ms 768 KB
subtask_1_02.txt WA 20 ms 640 KB
subtask_1_03.txt WA 13 ms 512 KB
subtask_1_04.txt WA 41 ms 1024 KB
subtask_1_05.txt WA 41 ms 1024 KB
subtask_1_06.txt WA 41 ms 1024 KB
subtask_1_07.txt WA 42 ms 1024 KB
subtask_1_08.txt WA 41 ms 1024 KB
subtask_1_09.txt WA 41 ms 1024 KB
subtask_1_10.txt WA 1 ms 256 KB
subtask_1_11.txt WA 1 ms 256 KB