#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
const int maxn = 1e6 + 5;
int n, q;
vl arr;
ll parent[maxn];
ll sz[maxn];
bool on[maxn];
int find(int v){
if(v == parent[v])
return v;
return parent[v] = find(parent[v]);
}
ll rez = 0;
void mrg(int a, int b){
a = find(a);
b = find(b);
if(a != b){
rez -= (sz[a] * (sz[a] + 1) * 1LL) / 2;
rez -= (sz[b] * (sz[b] + 1)*1LL) / 2;
sz[a] += sz[b];
rez += (sz[a] * (sz[a] + 1)*1LL) / 2;
parent[b] = a;
}
}
vl G[maxn];
ll ans[maxn];
int main(){
ios_base::sync_with_stdio(false);c
cin.tie(0);
cout.tie(0);
cin>>n>>q;
arr.resize(n);
for(int i = 0; i < n; i++){
parent[i] = i;
sz[i] = 1;
}
for(int i = 0; i < n; i++){
cin>>arr[i];
G[arr[i]].pb(i);
}
for(int i = 1; i <= 1000000; i++){
for(int x : G[i]){
++rez;
on[x] = 1;
if(x && on[x-1]) mrg(x, x-1);
if(x != n-1 && on[x+1]) mrg(x, x + 1);
}
ans[i] = rez;
}
for(int i = 0; i < q; i++){
ll a;
cin>>a;
cout<<ans[a]<<endl;
}
}
Compilation message
pilot.cpp: In function 'int main()':
pilot.cpp:36:35: error: 'c' was not declared in this scope
36 | ios_base::sync_with_stdio(false);c
| ^