#include <bits/stdc++.h>
#ifndef SKY
#include "plants.h"
#endif // SKY
using namespace std;
#define N 1000010
#define ll long long
#define fs first
#define sc second
#define ii pair<ll,int>
#define pb push_back
int k,n,h[N],a[N];
bool check(int u)
{
if(a[u]!=0)
return 0;
for(int j=1;j<k;j++)
if(a[(u-j+n)%n]==0)
return 0;
return 1;
}
void init(int cc, vector<int> r)
{
k=cc;
n=r.size();
for(int i=0;i<n;i++)
a[i]=r[i];
int dem=n;
for(int t=0;t<n;t++)
{
for(int i=0;i<n;i++)
if(check(i))
{
h[i]=--dem;
for(int j=0;j<k;j++)
a[(i-j+n)%n]--;
break;
}
}
// for(int i=0;i<n;i++)cout<<h[i]<<" ";
}
int compare_plants(int x, int y)
{
if(h[x]<h[y])
return -1;
else return 1;
}
#ifdef SKY
int main()
{
freopen("A.inp","r",stdin);
freopen("A.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int n,k;
cin>>n>>k;
vector<int>r(n);
for(int i=0;i<n;i++)
cin>>r[i];//,cout<<r[i]<<endl;
init(k,r);
int q;
cin>>q;
while(q--)
{
int x,y;
cin>>x>>y;
cout<<compare_plants(x,y)<<endl;
}
return 0;
}
#endif
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
9 ms |
424 KB |
Output is correct |
7 |
Correct |
242 ms |
5088 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
9 ms |
340 KB |
Output is correct |
10 |
Correct |
241 ms |
5052 KB |
Output is correct |
11 |
Correct |
167 ms |
4980 KB |
Output is correct |
12 |
Correct |
171 ms |
5196 KB |
Output is correct |
13 |
Correct |
284 ms |
5176 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
9 ms |
424 KB |
Output is correct |
7 |
Correct |
242 ms |
5088 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
9 ms |
340 KB |
Output is correct |
10 |
Correct |
241 ms |
5052 KB |
Output is correct |
11 |
Correct |
167 ms |
4980 KB |
Output is correct |
12 |
Correct |
171 ms |
5196 KB |
Output is correct |
13 |
Correct |
284 ms |
5176 KB |
Output is correct |
14 |
Correct |
2180 ms |
5580 KB |
Output is correct |
15 |
Execution timed out |
4050 ms |
9556 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
50 ms |
3748 KB |
Output is correct |
4 |
Execution timed out |
4058 ms |
8240 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |