链接:
https://codeforces.com/problemset/problem/474/B
题意:
n个堆的长度,求某个数在哪个堆里
解:
暴力
实际代码:
#include<iostream>
#include<cstring>
#define csh(a) memset(a,0,sizeof(a))
using namespace std;
const int N=1E6+10;
int ans[N];
int main()
{
csh(ans);
int n;
cin>>n;
int j=1;
for(int f=1;f<=n;f++)
{
int temp;
cin>>temp;
for(int k=1;k<=temp;k++)
{
ans[j++]=f;
}
}
int m;
cin>>m;
for(int i=1;i<=m;i++)
{
int temp;
cin>>temp;
cout<<ans[temp]<<endl;
}
}
限制:
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output