結果
| 問題 |
No.2931 Shibuya 109
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-11 23:08:33 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,363 ms / 4,000 ms |
| コード長 | 626 bytes |
| コンパイル時間 | 6,228 ms |
| コンパイル使用メモリ | 309,348 KB |
| 実行使用メモリ | 11,408 KB |
| 最終ジャッジ日時 | 2024-10-11 23:08:57 |
| 合計ジャッジ時間 | 23,347 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using mint=atcoder::modint998244353;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define int long long
signed main(){
int n,q;cin>>n>>q;
vector<int> a(n);for(auto&&e:a)cin>>e;
vector<int> v,vv;
for(int i=0;i<n;i++){
if(a[i]==1){
v.push_back(i);
}
if(a[i]==9){
vv.push_back(i);
}
}
while(q--){
int l,r;cin>>l>>r;l--;
int ans=lower_bound(vv.begin(),vv.end(),r)-lower_bound(vv.begin(),vv.end(),l);
for(auto&&e:v){
if(l<=e&&e<r){
ans+=r-e-1;
}
}
cout<<ans<<endl;
}
}