I.Letters
算法:前缀和+二分(lower_bound)
不开ll见祖宗
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t,n,m;
const int N=2e5+10;
#define eps(a,b) for(int i=a;i<=b;i++)
ll b[N],s[N];
int main()
{
ios::sync_with_stdio(false);cin.tie();cout.tie();
cin>>n>>m;
eps(1,n){cin>>s[i];s[i]+=s[i-1];}
eps(1,m)cin>>b[i];
eps(1,m)
{
int pose=lower_bound(s+1,s+1+n,b[i])-s;
//cout<<pose<<' ';
//if(s[pose-1]>b[i])
//ll l=0,r=a[i];
cout<<pose<<' ';
cout<<b[i]-s[pose-1]<<endl;
//cout<<b[i]<<endl;
}
return 0;
}
标签:cin,--,ll,bound,eps,int,补题
From: https://www.cnblogs.com/yuexiabaobei/p/17928260.html