Submission #1438489
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define MOD 1000000007
#define EPS 1e-10
//#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%d", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
signed main()
{
Int(n);
vp data(n);
rep(i, n) {
cin >> data[i].fir;
data[i].sec = i+1;
}
sort(all(data));
set<int> st;
st.insert(0);
st.insert(n+1);
int ans = 0;
rep(i, n) {
int num = data[i].fir, pos = data[i].sec;
// cout << pos << endl;
st.insert(pos);
auto ptr = st.find(pos);
auto l = --ptr;
ptr++; auto r = ++ptr;
ptr--;
ans += (pos - *l) * num * (*r - pos);
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time
2017-07-19 18:46:00+0900
Task
B - Minimum Sum
User
Ti11192916
Language
C++14 (GCC 5.4.1)
Score
0
Code Size
1441 Byte
Status
WA
Exec Time
166 ms
Memory
11136 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:23:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
#define Int(x) int x; scanf("%d", &x);
^
./Main.cpp:37:5: note: in expansion of macro ‘Int’
Int(n);
^
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
164 ms
11136 KB
corner1
WA
166 ms
11136 KB
corner2
AC
1 ms
256 KB
corner3
WA
130 ms
11136 KB
example0
AC
1 ms
256 KB
example1
AC
1 ms
256 KB
example2
AC
1 ms
256 KB
maxrand0
WA
163 ms
11136 KB
maxrand1
WA
164 ms
11136 KB
maxrand2
WA
163 ms
11136 KB
rand0
AC
1 ms
256 KB
rand1
AC
1 ms
256 KB
rand2
AC
1 ms
256 KB