Submission #320848

#TimeUsernameProblemLanguageResultExecution timeMemory
320848vishesh312Pilot (NOI19_pilot)C++17
55 / 100
1071 ms2404 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define deb(x) cerr << #x << " = " << x << "\n"; #define deb2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << "\n"; #define deb3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << "\n"; #define pb push_back #define eb emplace_back #define mp make_pair #define f first #define s second #define all(x) begin(x), end(x) #define sz(x) (int)x.size() using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>; using ordered_multiset = tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>; typedef long long ll; ll binpow(ll a, ll b) { //a = a % mod; ll res = 1; while ( b > 0) { if (b&1) { res = (a*res);//%mod; } a = (a*a);//%mod; b >>= 1; } return res; } void solve(int tc) { ll n, q; cin >> n >> q; vector<ll> v(n); for (auto &x : v) cin >> x; while (q--) { ll ans = 0; ll h; cin >> h; ll last = 0; for (ll i = 0; i < n; ++i) { if (v[i] > h) { ll cur = i-last; ans += ((cur+1)*cur)/2; last = i+1; } } ll cur = n-last; ans += ((cur+1)*cur)/2; cout << ans << '\n'; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int tc = 1; //cin >> tc; for (int i = 1; i <= tc; ++i) { solve(i); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...