Submission #2214590
Source Code Expand
#include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int,int> P; const ll MOD=1000000007; const ll INF=100000000000000LL; const int MAX=100001; const double EPS=1e-10; int main() { int n; cin>>n; vector<P> v; set<int> st; for(int i=0;i<n;i++){ int a; cin>>a; v.push_back(P(a,i)); } ll ans=0; sort(v.begin(),v.end()); st.insert(-1);st.insert(n); for(auto e:v){ st.insert(e.second); auto itr=st.find(e.second); ll l,r; itr--; l=*itr; itr++;itr++; r=*itr; ans+=(ll)(e.second-l)*(ll)(r-e.second)*(ll)e.first; } cout<<ans<<endl; }
Submission Info
Submission Time | |
---|---|
Task | B - Minimum Sum |
User | TAISA_ |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 726 Byte |
Status | AC |
Exec Time | 166 ms |
Memory | 11248 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0, example1, example2 |
All | corner0, corner1, corner2, corner3, example0, example1, example2, maxrand0, maxrand1, maxrand2, rand0, rand1, rand2 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
corner0 | AC | 140 ms | 11120 KB |
corner1 | AC | 140 ms | 11248 KB |
corner2 | AC | 1 ms | 256 KB |
corner3 | AC | 130 ms | 11120 KB |
example0 | AC | 1 ms | 256 KB |
example1 | AC | 1 ms | 256 KB |
example2 | AC | 1 ms | 256 KB |
maxrand0 | AC | 165 ms | 11248 KB |
maxrand1 | AC | 165 ms | 11248 KB |
maxrand2 | AC | 166 ms | 11248 KB |
rand0 | AC | 1 ms | 256 KB |
rand1 | AC | 1 ms | 256 KB |
rand2 | AC | 1 ms | 256 KB |