Submission #1839587
Source Code Expand
#include<bits/stdc++.h> using namespace std; int main(){ int n; long long t; cin >> n >> t; vector<long long> A(n); for(int i = 0; i < n; i++){ cin >> A[i]; } vector<long long> dp(n, 0); long long max_sell = A[n-1]; long long max_value = 0; for(int i = n-2; i >= 0; i--){ //cout << n-2 << endl dp[i] = max(dp[i], max_sell - A[i]); max_sell = max(max_sell, A[i]); max_value = max(max_value, dp[i]); } /*for(int i = 0; i < n; i++){ cout << i << " " << dp[i] << endl; }*/ int cost = 0; for(int i = 0; i < n; i++){ if(dp[i] == max_value) cost++; } cout << cost << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - An Invisible Hand |
User | monkukui |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 747 Byte |
Status | AC |
Exec Time | 41 ms |
Memory | 1792 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 | 41 ms | 1792 KB |
large_02.txt | AC | 29 ms | 1792 KB |
random_01.txt | AC | 41 ms | 1792 KB |
random_02.txt | AC | 41 ms | 1792 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 | 1792 KB |
spec_02.txt | AC | 41 ms | 1792 KB |
spec_03.txt | AC | 41 ms | 1792 KB |
spec_04.txt | AC | 41 ms | 1792 KB |
spec_05.txt | AC | 41 ms | 1792 KB |
spec_06.txt | AC | 41 ms | 1792 KB |