Submission #312841

# Submission time Handle Problem Language Result Execution time Memory
312841 2020-10-14T12:40:15 Z daringtrifles Mountains (NOI20_mountains) C++17
36 / 100
2000 ms 8088 KB
//control+option+n to run!
#include <bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define ll long long
#define pll pair<ll, ll>
#define FOR(i, a, b) for (signed long long i = (signed long long)(a); i < (signed long long)(b); i++)
#define NEGFOR(i, a, b) for (ll i = (a); i > (b); i--)
#define vll vector<long long>
#define sll set<long long>
#define ld long double
#define inf 1000000000000000000
#define mll multiset<long long>
#define vpll vector<pll>
#define nn << "\n"
#define ss << " "
#define F(i, b) for (ll i = 0; i < b; i++)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vll v(n);
    FOR(i, 0, n)
        cin >> v[i];
    vll before(n, 0), after(n, 0), x;
    ll ans = 0;
    x.pb(v[0]);
    FOR(i, 1, n)
    {
        before[i] = lower_bound(x.begin(), x.end(), v[i]) - x.begin();
        x.pb(v[i]);
        sort(x.begin(), x.end());
    }
 
    x={};
 
    x.pb(v[n-1]);
    FOR(i, 1, n)
    {
        after[i] = lower_bound(x.begin(), x.end(), v[n-i-1])-x.begin();
        x.pb(v[n-i-1]);
        sort(x.begin(), x.end());
    }
    FOR(i,0,n){
        ans+=before[i]*after[n-1-i];
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Execution timed out 2082 ms 8076 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2079 ms 8088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2079 ms 8088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 320 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 320 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Execution timed out 2069 ms 952 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2079 ms 8088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Execution timed out 2082 ms 8076 KB Time limit exceeded
3 Halted 0 ms 0 KB -