Submission #2098949
Source Code Expand
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,t;
ll a[100000];
int main(){
cin >> n >> t;
REP(i,n) {
cin >> a[i];
}
ll maxi = 0,mini = a[0];
FOR(i,1,n) {
maxi = max(maxi,a[i] - mini);
if(a[i] < mini)
mini = a[i];
}
mini = 0;ll ans = 0;
FOR(i,1,n) {
if(a[i] - a[mini] == maxi) {
ans ++;
}
if(a[i] < a[mini]) {
mini = i;
}
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
D - An Invisible Hand |
User |
kyawakyawa |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
829 Byte |
Status |
AC |
Exec Time |
44 ms |
Memory |
1024 KB |
Judge Result
Set Name |
sample |
All |
Score / Max Score |
0 / 0 |
400 / 400 |
Status |
|
|
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 |
44 ms |
1024 KB |
large_02.txt |
AC |
29 ms |
1024 KB |
random_01.txt |
AC |
41 ms |
1024 KB |
random_02.txt |
AC |
40 ms |
1024 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 |
41 ms |
1024 KB |
spec_02.txt |
AC |
41 ms |
1024 KB |
spec_03.txt |
AC |
41 ms |
1024 KB |
spec_04.txt |
AC |
41 ms |
1024 KB |
spec_05.txt |
AC |
41 ms |
1024 KB |
spec_06.txt |
AC |
41 ms |
1024 KB |