Submission #1475137


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> a(N); rep(i, 0, N) {
		cin >> a[i];
	}
	int ans = 0;
	rep(i, 0, N) {
		int minl, minr;
		int l, r;
		l = r = 1;
		minl = minr = a[i];
		rep(j, i + 1, N) {
			if (minl > a[j])break;
			l++;
		}
		rrep(j, 0, i) {
			if (minr > a[j])break;
			r++;
		}
		ans += l*r*a[i];
	}
	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 1015 Byte
Status WA
Exec Time 2103 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 7
WA × 3
TLE × 3
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 TLE 2103 ms 1024 KB
corner1 TLE 2103 ms 1024 KB
corner2 AC 1 ms 256 KB
corner3 TLE 2103 ms 1024 KB
example0 AC 1 ms 256 KB
example1 AC 1 ms 256 KB
example2 AC 1 ms 256 KB
maxrand0 WA 24 ms 1024 KB
maxrand1 WA 24 ms 1024 KB
maxrand2 WA 24 ms 1024 KB
rand0 AC 1 ms 256 KB
rand1 AC 1 ms 256 KB
rand2 AC 1 ms 256 KB