Submission #223604

#TimeUsernameProblemLanguageResultExecution timeMemory
223604blackboriPilot (NOI19_pilot)C++14
100 / 100
472 ms33096 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll D[1010101]; int A[1010101], S[1010101]; int n; int main() { ios::sync_with_stdio(0); cin.tie(0); int q, i, j, t; cin >> n >> q; for(i = 1, j = 0, A[0] = 1e6 + 1; i <= n; i ++){ cin >> A[i]; for(; j && A[S[j]] < A[i]; j --){ D[A[S[j]]] += (ll)(i - S[j]) * (S[j] - S[j - 1]); } S[++ j] = i; } for(; j; j --){ D[A[S[j]]] += (ll)(i - S[j]) * (S[j] - S[j - 1]); } for(i = 1; i <= 1e6; i ++){ D[i] += D[i - 1]; } for(; q --; ){ cin >> t; cout << D[t] << "\n"; } 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...