# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
529166 |
2022-02-22T10:40:14 Z |
ToroTN |
Martian DNA (BOI18_dna) |
C++14 |
|
48 ms |
3392 KB |
#include<bits/stdc++.h>
using namespace std;
int n,m,t,want[15],num1,num2,a[200005],st,md,ed,hsh[15],cnt,type;
int main()
{
scanf("%d%d%d",&n,&m,&t);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
a[i]+=1;
}
while(t--)
{
scanf("%d%d",&num1,&num2);
want[num1+1]=max(want[num1+1],num2);
}
st=1;
ed=n;
while(ed>=st)
{
type=-1;
md=(st+ed)/2;
//printf("%d %d %d\n",st,md,ed);
memset(hsh,0,sizeof hsh);
for(int i=1;i<=md;i++)
{
++hsh[a[i]];
}
cnt=0;
for(int j=1;j<=m;j++)
{
if(hsh[j]>=want[j])
{
++cnt;
}
}
/*for(int j=1;j<=m;j++)
{
printf("%d ",hsh[j]);
}
printf("\n");*/
if(cnt==m)
{
type=0;
}
for(int i=2;i<=n-md+1;i++)
{
--hsh[a[i-1]];
++hsh[a[i+md-1]];
/*for(int j=1;j<=m;j++)
{
printf("%d ",hsh[j]);
}
printf("\n");*/
cnt=0;
for(int j=1;j<=m;j++)
{
if(hsh[j]>=want[j])
{
++cnt;
}
}
if(cnt==m)
{
type=0;
}
}
if(type==0)
{
ed=md-1;
}else
{
st=md+1;
}
}
if(st==n+1)
{
printf("impossible\n");
}else
{
printf("%d\n",st);
}
}
Compilation message
dna.cpp: In function 'int main()':
dna.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
6 | scanf("%d%d%d",&n,&m,&t);
| ~~~~~^~~~~~~~~~~~~~~~~~~
dna.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
9 | scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
dna.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | scanf("%d%d",&num1,&num2);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
304 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Incorrect |
16 ms |
332 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
1452 KB |
Output is correct |
2 |
Correct |
33 ms |
1528 KB |
Output is correct |
3 |
Correct |
48 ms |
1488 KB |
Output is correct |
4 |
Correct |
39 ms |
1432 KB |
Output is correct |
5 |
Runtime error |
19 ms |
3060 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
17 ms |
3392 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |