【模拟试题】光亮
题目跳转:【模拟试题】 BS体验
这道题很简单:从左往右和从右往左扫一遍。
我们设light为现在这个位置的光,则有两种情况:
- 这个地方是没有灯的:
那么这个位置就是现在的light。
- 这个地方有灯:
这个地方的light设为当前亮度。
此时我们必须要注意一个细节:如果现在的light比这个位置的亮度要亮,那么这个位置的这个光就没有意义,所以要处理一下。
代码:
#include<bits/stdc++.h>
using namespace std;
#define cin(x) scanf("%d",&x)
#define cout(x) printf("%d ",x)
#define endl puts("")
const int M = 1e7+100;
const int N = 1e7+100;
int n,m,q,a[M],b[M],t,x,cnt,ans[M],mp[M];
int Abs(int a){
return a>0?a:-a;
}
signed main(){
// freopen("bright.in","r",stdin);
// freopen("bright.out","w",stdout);
cin(n);cin(m);cin(q);
for(int i = 1;i<=m;i++){
cin(a[i]);cin(b[i]);
mp[a[i]] = b[i];
}
int j = 1,light=0;
/*从左往右扫一遍*/
j = m,light=0;
/*从右往左扫一遍*/
for(int i = 1;i<=q;i++){
cin(x);
cout(ans[x]);
}
return 0;
}