QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#883896 | #10052. Just Long Neckties 2 | dxbt | 0 | 1164ms | 7412kb | C++14 | 1.3kb | 2025-02-05 19:44:53 | 2025-02-05 19:44:53 |
Judging History
answer
#include<bits/stdc++.h>
#define F(i,l,r) for(int i=(l),i##end=(r);i<=i##end;++i)
#define G(i,l,r) for(int i=(l),i##end=(r);i>=i##end;--i)
#define x first
#define y second
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
#define ep emplace_back
using namespace std;
typedef long long ll;
int a[5000009];
void read(int &x)
{
x=0;
char ch=getchar();
while(ch<'0'||ch>'9')ch=getchar();
while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
}
mt19937 rnd(time(0));
int p[100];
int main()
{
int n;
read(n);
F(i,1,n)read(a[i]);
int T=100;
int score=22;
while(T--)
{
int x=0;bool flag=true;
F(i,1,n)
{
int mn=100,mx=0;
F(j,1,x)
{
mn=min(mn,p[j]);
if(p[j]<=a[i]&&p[j]>=p[mx])mx=j;
}
if(p[mx]==a[i])
{
flag=true;
continue;
}
if(!flag)
{
if(mx!=0)p[mx]=a[i];
else p[++x]=a[i];
flag=true;
continue;
}
if(mx==0&&a[i]<mn&&a[i]>a[i+1])
{
flag=false;
continue;
}
if(mx==0&&a[i]>a[i+1])
{
flag=false;
continue;
}
if(a[i]>a[i+1]&&a[i+1]>=mn)
{
flag=false;
continue;
}
if(mx!=0)p[mx]=a[i];
else p[++x]=a[i];
flag=true;
}
score=min(score,x);
}
cout<<score<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 1ms
memory: 3456kb
input:
15 2 19 3 6 1 18 20 9 17 19 18 4 15 7 16
output:
3
result:
ok single line: '3'
Test #2:
score: 10
Accepted
time: 0ms
memory: 3584kb
input:
15 13 6 13 10 3 6 18 8 20 14 11 15 12 12 15
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Wrong Answer
time: 1ms
memory: 3584kb
input:
15 3 6 7 9 10 6 12 13 5 13 14 16 17 6 18
output:
3
result:
wrong answer 1st lines differ - expected: '1', found: '3'
Subtask #2:
score: 0
Wrong Answer
Test #19:
score: 6
Accepted
time: 0ms
memory: 3584kb
input:
500 1 1 2 2 2 2 2 1 2 2 1 1 1 1 2 1 1 2 1 2 1 2 1 1 2 2 2 2 1 1 1 2 2 1 1 1 2 1 1 1 1 1 2 1 2 2 1 2 1 2 2 1 2 1 1 2 2 1 2 1 2 1 1 1 1 2 2 1 2 1 1 2 1 2 2 1 1 1 2 1 2 1 1 2 2 2 1 2 2 2 2 1 1 2 1 2 1 2 1 2 1 2 1 2 2 2 1 2 2 2 2 2 2 1 1 1 2 1 1 2 1 2 2 2 1 1 1 1 2 2 2 2 1 1 2 2 1 2 2 1 2 2 2 1 2 2 1 1 ...
output:
2
result:
ok single line: '2'
Test #20:
score: 6
Accepted
time: 0ms
memory: 3584kb
input:
500 1 2 1 1 2 2 1 2 1 1 2 1 2 1 1 1 1 2 2 1 1 2 2 2 1 1 1 1 2 2 1 2 1 2 2 2 1 1 2 2 2 1 1 1 1 2 1 1 2 1 1 2 2 1 2 2 1 1 1 1 2 2 2 2 1 1 2 1 2 2 2 2 2 1 2 2 1 1 2 1 2 2 1 1 1 2 1 2 1 2 1 2 1 1 1 2 2 1 1 1 1 2 2 2 2 1 1 1 1 1 2 1 2 2 2 2 1 2 1 2 2 1 1 1 2 2 1 1 1 2 2 1 2 2 2 1 1 1 2 2 1 1 2 2 2 2 1 1 ...
output:
2
result:
ok single line: '2'
Test #21:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
input:
500 2 1 2 2 2 2 2 2 2 1 2 2 1 2 1 2 1 2 1 2 2 1 2 1 2 2 2 1 2 2 1 2 2 2 2 1 2 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 1 2 2 2 1 2 1 2 1 2 2 1 2 1 2 2 1 2 2 1 2 2 1 2 1 2 1 2 1 2 2 1 2 1 2 2 2 1 2 1 2 2 1 2 2 1 2 2 2 2 2 1 2 1 2 2 1 2 2 2 1 2 2 1 2 1 2 1 2 1 2 2 1 2 2 1 2 1 2 1 2 1 2 1 2 2 2 1 2 1 2 2 2 2 1 2 ...
output:
2
result:
wrong answer 1st lines differ - expected: '1', found: '2'
Subtask #3:
score: 0
Wrong Answer
Test #34:
score: 12
Accepted
time: 1ms
memory: 3584kb
input:
500 2 5 4 4 4 1 1 4 5 1 1 2 2 1 4 3 3 1 4 5 4 3 1 1 3 4 4 2 2 3 1 1 1 1 3 3 5 2 1 2 1 1 4 1 4 4 1 2 2 5 3 4 2 3 2 3 5 3 3 1 5 3 4 5 1 2 5 5 2 1 5 1 4 2 2 2 1 2 1 2 2 1 4 2 3 5 1 2 5 2 1 2 5 3 3 5 3 1 3 4 3 3 1 3 4 4 5 1 2 2 2 3 2 5 3 5 3 1 4 5 1 1 5 3 3 5 4 3 1 5 1 5 5 1 5 5 2 4 3 2 5 3 3 2 4 3 1 3 ...
output:
5
result:
ok single line: '5'
Test #35:
score: 12
Accepted
time: 0ms
memory: 3584kb
input:
500 4 5 3 3 2 5 3 2 4 3 5 4 1 5 2 2 2 4 2 1 5 5 5 1 1 2 3 1 4 4 2 3 3 3 1 4 4 1 2 1 1 1 4 2 3 1 4 1 3 3 5 4 5 2 3 5 1 5 1 2 2 5 2 2 5 1 4 2 4 2 2 1 4 5 3 2 2 2 2 2 3 1 1 5 2 4 2 4 2 2 3 2 5 3 2 1 2 5 5 2 3 1 4 5 1 4 4 4 1 3 4 1 1 3 2 5 1 4 4 2 3 1 5 5 4 2 4 1 4 3 2 1 3 4 4 3 1 3 2 5 3 3 5 5 4 4 4 5 ...
output:
5
result:
ok single line: '5'
Test #36:
score: 0
Wrong Answer
time: 1ms
memory: 3584kb
input:
500 1 1 4 1 1 3 1 1 3 1 5 1 1 1 5 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 3 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 3 1 1 1 1 4 1 1 2 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 4 1 3 1 1 1 2 2 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 2 2 1 2 2 2 2 2 2 5 2 2 1 2 3 2 2 1 2 2 2 2 2 5 2 2 1 ...
output:
5
result:
wrong answer 1st lines differ - expected: '1', found: '5'
Subtask #4:
score: 0
Wrong Answer
Test #53:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
input:
500 2 1 12 3 13 13 7 9 7 3 14 10 9 13 6 3 9 1 10 10 7 13 6 9 10 13 3 7 15 12 14 4 1 5 4 3 8 7 3 14 5 1 6 13 1 3 4 10 5 8 3 6 2 4 10 1 13 5 6 13 12 10 14 15 8 9 13 10 9 14 4 9 13 12 4 7 12 4 2 14 6 12 5 4 6 12 13 6 2 12 10 5 6 5 1 1 5 1 5 12 11 3 6 13 11 10 1 8 14 9 5 5 15 1 15 3 15 10 4 6 9 14 1 5 1...
output:
14
result:
wrong answer 1st lines differ - expected: '10', found: '14'
Subtask #5:
score: 0
Wrong Answer
Test #73:
score: 26
Accepted
time: 948ms
memory: 5720kb
input:
500000 13 6 2 6 3 6 13 5 9 8 4 12 10 7 1 7 10 14 15 15 1 9 4 4 1 14 3 8 13 2 8 11 14 14 4 13 8 9 13 14 9 7 3 15 7 7 1 11 11 11 2 13 11 15 3 4 8 12 9 4 10 4 10 13 4 9 14 11 7 13 10 4 9 14 12 14 11 5 7 6 14 1 6 14 10 9 2 14 8 8 8 9 7 1 15 3 11 3 3 5 13 1 15 7 4 7 15 3 15 14 14 2 4 12 5 13 12 11 3 1 12...
output:
15
result:
ok single line: '15'
Test #74:
score: 26
Accepted
time: 949ms
memory: 6404kb
input:
500000 8 7 9 12 2 7 1 11 10 12 14 3 1 4 10 12 8 12 7 14 2 3 4 8 3 8 14 13 4 10 6 10 6 10 6 12 7 2 3 4 9 13 13 2 2 8 9 6 2 1 9 3 9 6 3 8 12 3 4 7 2 6 12 12 4 9 3 15 1 7 2 1 9 14 2 8 12 6 14 6 6 10 2 15 2 14 11 1 1 2 13 9 1 14 2 5 2 13 1 9 15 7 3 12 10 10 5 13 8 9 6 6 8 9 4 8 1 2 10 13 4 7 15 9 4 14 7...
output:
15
result:
ok single line: '15'
Test #75:
score: 0
Wrong Answer
time: 442ms
memory: 5708kb
input:
500000 1 6 1 1 1 1 1 1 1 4 1 9 1 1 1 1 1 1 1 1 1 1 10 1 1 11 1 1 1 10 1 13 1 1 1 1 6 1 1 1 1 9 1 1 1 1 14 1 1 1 4 1 1 11 1 1 7 1 12 1 1 1 8 1 1 1 3 1 1 1 1 15 1 1 1 1 11 1 8 1 1 1 1 1 8 1 1 1 1 8 1 1 1 1 1 1 1 1 1 7 1 1 1 1 1 11 1 13 1 1 1 13 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 5 1 1 10 1 1 1 1 1 ...
output:
15
result:
wrong answer 1st lines differ - expected: '1', found: '15'
Subtask #6:
score: 0
Wrong Answer
Test #93:
score: 10
Accepted
time: 1158ms
memory: 7412kb
input:
500000 18 13 10 17 5 21 13 19 14 14 11 5 11 21 9 15 1 12 4 17 10 18 14 10 1 14 8 15 6 10 7 13 17 12 7 2 11 20 12 8 13 21 3 1 1 5 15 8 9 14 15 15 12 12 15 7 21 12 1 8 7 20 2 1 12 18 4 4 17 1 1 6 12 6 21 12 7 11 17 5 5 19 7 21 21 16 13 17 5 16 19 14 3 3 5 4 15 2 21 12 20 21 1 2 16 15 5 17 12 4 11 19 1...
output:
21
result:
ok single line: '21'
Test #94:
score: 10
Accepted
time: 1164ms
memory: 6660kb
input:
500000 3 14 11 18 13 6 14 19 1 3 13 2 11 10 21 7 17 20 5 7 7 9 10 8 7 5 2 10 19 12 5 16 21 15 15 1 9 21 5 18 2 20 9 2 5 21 12 15 9 9 17 9 13 8 18 11 16 16 19 5 18 9 3 1 1 3 15 3 6 17 3 2 20 3 1 10 15 20 16 4 2 1 4 19 8 6 7 10 3 10 11 21 10 8 21 14 6 4 4 11 9 21 4 10 21 13 16 6 10 2 15 17 11 21 10 6 ...
output:
21
result:
ok single line: '21'
Test #95:
score: 0
Wrong Answer
time: 558ms
memory: 6008kb
input:
500000 1 1 1 14 1 1 14 1 1 1 1 1 1 1 1 1 1 12 1 1 1 1 13 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 1 1 1 12 1 1 1 1 1 1 1 1 1 5 1 1 1 20 1 1 1 1 1 1 1 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 17 1 3 1 1 1 1 13 1 1 1 1 1 17 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 19 1 5 1 1 11 1 1 1 1 1 15 1 16 1 1 1 8 1 1 17 1 1 1 20 1 1 1 1 1 1...
output:
21
result:
wrong answer 1st lines differ - expected: '1', found: '21'
Subtask #7:
score: 0
Time Limit Exceeded
Test #122:
score: 0
Time Limit Exceeded
input:
5000000 13 18 3 21 9 14 1 14 7 16 2 17 21 12 14 1 1 15 15 18 18 16 19 18 2 3 13 5 14 14 13 3 2 9 3 20 7 17 16 14 13 8 21 12 6 3 6 13 2 19 3 5 14 21 3 11 21 10 12 14 3 13 21 13 1 8 8 16 9 10 17 5 17 3 11 10 2 9 15 11 15 13 10 12 6 8 16 21 11 9 15 17 18 1 20 14 16 3 18 5 5 6 12 16 6 7 5 16 11 11 18 16...