# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
260877 |
2020-08-11T06:35:06 Z |
최은수(#5044) |
수확 (JOI20_harvest) |
C++17 |
|
5000 ms |
338584 KB |
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
vector<pl>lst[3010];
int chk[200010];
int cur;
ll tim[200010];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,m,q;
ll l,c;
cin>>n>>m>>l>>c;
vector<int>np(n);
vector<ll>pp(n),app(m),npt(n);
for(ll&t:pp)
cin>>t;
for(int i=0;i<n;i++)
{
ll t=pp[i];
ll nxp=((t-c)%l+l)%l;
np[i]=upper_bound(all(pp),nxp)-pp.begin()-1;
if(np[i]<0)
np[i]+=n;
npt[i]=(pp[np[i]]>nxp?l-(pp[np[i]]-nxp):nxp-pp[np[i]])+c;
}
for(ll&t:app)
{
cin>>t;
int id=upper_bound(all(pp),t)-pp.begin()-1;
if(id<0)
id+=n;
ll tm=pp[id]>t?l-(pp[id]-t):t-pp[id];
cur+=2;
for(;chk[id]!=cur;tm+=npt[id],id=np[id])
{
if(chk[id]==cur-1)
{
lst[id].eb(tim[id],tm-tim[id]);
chk[id]=cur;
}
else
{
lst[id].eb(tim[id]=tm,-1);
chk[id]=cur-1;
}
tim[id]=tm;
}
}
cin>>q;
for(int i=0;i<q;i++)
{
int x;
ll t;
cin>>x>>t;
x--;
ll ans=0;
for(pl&a:lst[x])
if(t>=a.fi)
ans+=a.se==-1?1:(t-a.fi)/a.se;
cout<<ans<<'\n';
}
cout.flush();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
768 KB |
Output is correct |
3 |
Correct |
101 ms |
896 KB |
Output is correct |
4 |
Correct |
20 ms |
11776 KB |
Output is correct |
5 |
Correct |
145 ms |
92764 KB |
Output is correct |
6 |
Correct |
144 ms |
92152 KB |
Output is correct |
7 |
Correct |
167 ms |
93560 KB |
Output is correct |
8 |
Correct |
4 ms |
896 KB |
Output is correct |
9 |
Correct |
3 ms |
896 KB |
Output is correct |
10 |
Correct |
3 ms |
1024 KB |
Output is correct |
11 |
Correct |
4 ms |
1024 KB |
Output is correct |
12 |
Correct |
606 ms |
338584 KB |
Output is correct |
13 |
Correct |
697 ms |
338164 KB |
Output is correct |
14 |
Correct |
337 ms |
174312 KB |
Output is correct |
15 |
Correct |
86 ms |
50680 KB |
Output is correct |
16 |
Correct |
88 ms |
50040 KB |
Output is correct |
17 |
Correct |
82 ms |
49400 KB |
Output is correct |
18 |
Correct |
72 ms |
47736 KB |
Output is correct |
19 |
Correct |
72 ms |
48632 KB |
Output is correct |
20 |
Correct |
66 ms |
46712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5080 ms |
6092 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
768 KB |
Output is correct |
3 |
Correct |
101 ms |
896 KB |
Output is correct |
4 |
Correct |
20 ms |
11776 KB |
Output is correct |
5 |
Correct |
145 ms |
92764 KB |
Output is correct |
6 |
Correct |
144 ms |
92152 KB |
Output is correct |
7 |
Correct |
167 ms |
93560 KB |
Output is correct |
8 |
Correct |
4 ms |
896 KB |
Output is correct |
9 |
Correct |
3 ms |
896 KB |
Output is correct |
10 |
Correct |
3 ms |
1024 KB |
Output is correct |
11 |
Correct |
4 ms |
1024 KB |
Output is correct |
12 |
Correct |
606 ms |
338584 KB |
Output is correct |
13 |
Correct |
697 ms |
338164 KB |
Output is correct |
14 |
Correct |
337 ms |
174312 KB |
Output is correct |
15 |
Correct |
86 ms |
50680 KB |
Output is correct |
16 |
Correct |
88 ms |
50040 KB |
Output is correct |
17 |
Correct |
82 ms |
49400 KB |
Output is correct |
18 |
Correct |
72 ms |
47736 KB |
Output is correct |
19 |
Correct |
72 ms |
48632 KB |
Output is correct |
20 |
Correct |
66 ms |
46712 KB |
Output is correct |
21 |
Execution timed out |
5080 ms |
6092 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |