Submission #1475167
Source Code Expand
#include "bits/stdc++.h" using namespace std; #ifdef _DEBUG #include "dump.hpp" #else #define dump(...) #endif //#define int long long #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) #define all(c) begin(c),end(c) const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = (int)(1e9) + 7; template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } signed main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> pos(N); vector<int> a(N); rep(i, 0, N) { cin >> a[i]; a[i]--; pos[a[i]] = i; } set<int> st; st.insert(-1); st.insert(N); int ans = 0; rep(k, 0, N) { auto res = st.insert(pos[k]); set<int>::iterator l, r; l = r = res.first; l--; r++; ans += (k + 1)*(pos[k] - *l)*(*r - pos[k]); } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Minimum Sum |
User | minaminao |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1040 Byte |
Status | WA |
Exec Time | 91 ms |
Memory | 11264 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 78 ms | 11264 KB |
corner1 | WA | 79 ms | 11264 KB |
corner2 | AC | 1 ms | 256 KB |
corner3 | WA | 55 ms | 11264 KB |
example0 | AC | 1 ms | 256 KB |
example1 | AC | 1 ms | 256 KB |
example2 | AC | 1 ms | 256 KB |
maxrand0 | WA | 91 ms | 11264 KB |
maxrand1 | WA | 91 ms | 11264 KB |
maxrand2 | WA | 91 ms | 11264 KB |
rand0 | AC | 1 ms | 256 KB |
rand1 | AC | 1 ms | 256 KB |
rand2 | AC | 1 ms | 256 KB |