Submission #1248944


Source Code Expand

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
#include <map>
#include <list>
#include <bitset>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

Int solve(Int n, Int t, V& as){
    Int ans = 0;
    Int max_a = 0;
    Int min_a = INT_MAX;
    for(int i = 0; i < n; i++){
        min_a = min(min_a, as[i]);
        if(as[i] - min_a > max_a){
            max_a = as[i] - min_a;
            ans = 1;
        }else if(as[i] - min_a == max_a){
            ans++;
        }
    }
    return ans;
}


int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);

    Int n, t;
    cin >> n >> t;
    V as(n);
    for(int i = 0; i < n; i++){
        cin >> as[i];
    }

    cout << solve(n, t, as) << "\n";

    return 0;
}

Submission Info

Submission Time
Task D - An Invisible Hand
User proton06
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1223 Byte
Status AC
Exec Time 12 ms
Memory 640 KB

Judge Result

Set Name sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 15
Set Name Test Cases
sample sample_01.txt, sample_02.txt, sample_03.txt
All large_01.txt, large_02.txt, random_01.txt, random_02.txt, sample_01.txt, sample_02.txt, sample_03.txt, small_01.txt, small_02.txt, spec_01.txt, spec_02.txt, spec_03.txt, spec_04.txt, spec_05.txt, spec_06.txt
Case Name Status Exec Time Memory
large_01.txt AC 11 ms 640 KB
large_02.txt AC 9 ms 640 KB
random_01.txt AC 11 ms 640 KB
random_02.txt AC 11 ms 640 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
small_01.txt AC 1 ms 256 KB
small_02.txt AC 1 ms 256 KB
spec_01.txt AC 11 ms 640 KB
spec_02.txt AC 11 ms 640 KB
spec_03.txt AC 12 ms 640 KB
spec_04.txt AC 11 ms 640 KB
spec_05.txt AC 12 ms 640 KB
spec_06.txt AC 11 ms 640 KB