Submission #1533211


Source Code Expand

#include <iostream>
#include <vector>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ranked_index.hpp>

using namespace std;
using namespace boost::multi_index;
using Container = multi_index_container<
    int64_t,
    indexed_by<
        ranked_non_unique<identity<int64_t>>
    >
>;

int main()
{
    int n, k;
    cin >> n >> k;
    
    vector<int64_t> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    vector<int64_t> b(n + 1);
    for(int i = 0; i < n; i++) {
        b[i + 1] = b[i] + a[i] - k;   
    }
    
    Container c;
    int64_t ans = 0;
    
    for(int i = 0; i < n + 1; i++) {
        ans += c.upper_bound_rank(b[i]);
        c.insert(b[i]);
    }
    
    cout << ans << endl;
}

Submission Info

Submission Time
Task E - Meaningful Mean
User mino
Language C++14 (Clang 3.8.0)
Score 600
Code Size 785 Byte
Status AC
Exec Time 378 ms
Memory 12800 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 23
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23
Case Name Status Exec Time Memory
a01 AC 7 ms 888 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 364 ms 12800 KB
b06 AC 378 ms 12800 KB
b07 AC 315 ms 12800 KB
b08 AC 306 ms 12800 KB
b09 AC 298 ms 12800 KB
b10 AC 260 ms 12800 KB
b11 AC 1 ms 256 KB
b12 AC 2 ms 256 KB
b13 AC 103 ms 4736 KB
b14 AC 291 ms 12800 KB
b15 AC 174 ms 12800 KB
b16 AC 301 ms 12800 KB
b17 AC 294 ms 12800 KB
b18 AC 294 ms 12800 KB
b19 AC 301 ms 12800 KB
b20 AC 285 ms 12800 KB
b21 AC 276 ms 12800 KB
b22 AC 286 ms 12800 KB
b23 AC 279 ms 12800 KB