UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211989#3816. 元素zhangry00ms1224kbC++1.0kb2024-10-13 09:39:232024-10-13 12:10:01

answer

#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define awa return 0;
using namespace std;
const int maxn=2e3+10;
int n,q;
int a[maxn];
int l,r;
signed main()
{
    IOS;
    cin>>n,q;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=q;i++)
    {
        cin>>l>>r;
        int min_len=r-l+1;
        for(int j=l;j<=r;j++)
        {
            int minn=a[j],maxx=a[j];
            for(int k=i;k<=r;k++)
            {
                minn=min(minn,a[k]);
                maxx=max(maxx,a[k]);
                bool t=true;
                for(int p=i;p<=j;p++)
                {
                    if(a[p]<minn||a[p]>maxx)
                    {
                        t=false;
                        break;
                    }
                }
                if(t)
                {
                    min_len=min(min_len,k-j+1);
                }
            }
        }
        cout<<min_len<<endl;
    }
    awa
}
//

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1208kb

input:

10 10
492 1887 1028 1209 252 1860 1527 699 1656 928
6 9
2 8
3 10
2 3
1 8
6 9
3 5
4 7
1 4
2 7

output:


result:

wrong answer Answer contains longer sequence [length = 10], but output contains 0 elements

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 1208kb

input:

50 50
413 1208 1780 279 1403 1706 11 1583 333 355 1068 1270 1835 1042 957 423 1140 1153 1709 284 281...

output:


result:

wrong answer Answer contains longer sequence [length = 50], but output contains 0 elements

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 1208kb

input:

50 50
407 1089 1459 1626 1917 555 1611 492 443 1149 406 1259 1729 1554 577 1310 1899 1578 1005 1459 ...

output:


result:

wrong answer Answer contains longer sequence [length = 50], but output contains 0 elements

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 1208kb

input:

50 50
1792 843 1272 547 698 1086 1174 1607 1277 1055 506 881 1445 372 1076 1770 647 1086 320 1912 18...

output:


result:

wrong answer Answer contains longer sequence [length = 50], but output contains 0 elements

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 1204kb

input:

50 50
44 1463 245 1177 1728 1335 768 475 790 623 1466 98 672 230 339 1428 872 1905 405 1260 1503 813...

output:


result:

wrong answer Answer contains longer sequence [length = 50], but output contains 0 elements

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 1208kb

input:

50 50
695 974 1078 231 500 498 1308 1666 1925 766 1994 1776 1955 1766 1191 1021 1581 1202 615 1230 1...

output:


result:

wrong answer Answer contains longer sequence [length = 50], but output contains 0 elements

Test #7:

score: 0
Wrong Answer
time: 0ms
memory: 1204kb

input:

200 200
403 329 389 1103 695 1865 818 671 750 1868 1422 422 1186 1431 172 1569 460 1580 406 1049 138...

output:


result:

wrong answer Answer contains longer sequence [length = 200], but output contains 0 elements

Test #8:

score: 0
Wrong Answer
time: 0ms
memory: 1204kb

input:

200 200
147 1386 1788 1493 1919 1136 861 871 1895 1006 1776 346 381 1666 296 289 568 1616 1535 531 2...

output:


result:

wrong answer Answer contains longer sequence [length = 200], but output contains 0 elements

Test #9:

score: 0
Wrong Answer
time: 0ms
memory: 1224kb

input:

2000 2000
1154 852 1088 1530 639 1318 1250 1222 1341 1070 205 656 903 1491 808 317 756 1962 102 1445...

output:


result:

wrong answer Answer contains longer sequence [length = 2000], but output contains 0 elements

Test #10:

score: 0
Wrong Answer
time: 0ms
memory: 1224kb

input:

2000 2000
1232 731 1651 991 1681 1739 776 240 829 1337 493 248 214 1852 716 325 1280 1207 380 724 11...

output:


result:

wrong answer Answer contains longer sequence [length = 2000], but output contains 0 elements