Submission #971264


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n,t,a[100005],mx[100005],ans=0,m=0;
cin>>n>>t;

rep(i,1,n)cin>>a[i];
mx[n]=a[n];
ren(i,n-1,1)mx[i]=max(mx[i+1],a[i]);

rep(i,1,n-1)
{
	if(mx[i+1]-a[i]==m)
	ans++;
	else if(mx[i+1]-a[i]>m)
	{
		ans=1;m=mx[i+1]-a[i];
	}
}
ol(ans);

return 0;
}

Submission Info

Submission Time
Task D - An Invisible Hand
User abisheka
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1640 Byte
Status
Exec Time 14 ms
Memory 1024 KB

Test Cases

Set Name Score / Max Score Test Cases
sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 400 / 400 large_01.txt, large_02.txt, random_01.txt, random_02.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 14 ms 1024 KB
large_02.txt 12 ms 1024 KB
random_01.txt 14 ms 1024 KB
random_02.txt 14 ms 1024 KB
sample_01.txt 2 ms 256 KB
sample_02.txt 3 ms 256 KB
sample_03.txt 3 ms 256 KB
small_01.txt 3 ms 256 KB
small_02.txt 3 ms 256 KB
spec_01.txt 14 ms 1024 KB
spec_02.txt 14 ms 1024 KB
spec_03.txt 14 ms 1024 KB
spec_04.txt 14 ms 1024 KB
spec_05.txt 14 ms 1024 KB
spec_06.txt 14 ms 1024 KB