답안 #246454

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
246454 2020-07-09T11:21:36 Z bibabas Vudu (COCI15_vudu) C++14
42 / 140
1000 ms 15992 KB
#include <bits/stdc++.h>
 
#define ll long long
#define ull unsigned ll
#define vi vector<ll>
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define ld long double
#define pii pair<ll, ll>
#define mt make_tuple
#define mn(a, b) a = min(a, b)
#define mx(a, b) a = max(a, b)
 
using namespace std;
 
const ll INF = (ll)2e9;
const ll inf = (ll)2e18;
const ld eps = (ld)1e-8;
const ll mod = (ll)10007;
const ll MAXN = (ll)1e4 + 1;
const ll MAXC = (ll)1e6 + 1;
const ll MAXE = (ll)1000;
const ll MAXLOG = 21;
const ll maxlen = (ll)1e5;
const ll asci = (ll)256;
const ll block = 480;
const ld PI = acos(-1);
const ld e = 2.7182818284;
 
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<
pii,
null_type,
less<pii>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
 
template <class T>
istream& operator >>(istream &in, vector<T> &arr){
    for (T &cnt : arr) {
        in >> cnt;
    }
    return in;
};

void solve() {
    int n; cin >> n;
    vi a(n); cin >> a;
    int p; cin >> p;
    vi pref(n + 1);
    for (int i = 0; i < n; ++i) pref[i + 1] = pref[i] + a[i] - p;
    ll ans = 0;
    for (int l = 0; l < n; ++l) {
        for (int r = l + 1; r <= n; ++r) {
            if (pref[r] - pref[l] >= 0) ans++;
        }
    }
    cout << ans << "\n";
}

signed main() {
    srand(time(0));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#endif
    cout.precision(30);
    
    solve();
 
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 512 KB Output is correct
2 Correct 20 ms 384 KB Output is correct
3 Correct 19 ms 384 KB Output is correct
4 Execution timed out 1097 ms 15480 KB Time limit exceeded
5 Execution timed out 1061 ms 8952 KB Time limit exceeded
6 Execution timed out 1078 ms 13776 KB Time limit exceeded
7 Execution timed out 1094 ms 14328 KB Time limit exceeded
8 Execution timed out 1063 ms 12408 KB Time limit exceeded
9 Execution timed out 1096 ms 15992 KB Time limit exceeded
10 Execution timed out 1091 ms 13944 KB Time limit exceeded