QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#401145#5150. Alternating Algorithmucup-team1716#WA 0ms3840kbC++20950b2024-04-28 02:25:402024-04-28 02:25:41

Judging History

你现在查看的是最新测评结果

  • [2024-04-28 02:25:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2024-04-28 02:25:40]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int t = 1;
	//cin >> t;
    while(t-->0)
    {
        int n;
        cin >> n;

        n++;
        vector<pair<int, int>> a(n);
        for(int i=0; i<n; i++)
        {
            cin >> a[i].first;
            a[i].second = i;
        }
        sort(a.begin(), a.end());

        int M = 0;
        for(int i=0; i<n; i++)
        {
            int x = i - a[i].second;
            //cout << x << " ";
            if(a[i].second%2==0)
            {
                if(x>=0) M = max(M, x);
                else M = max(M, -x + 1);
            }
            else
            {
                if(x<=0) M = max(M, -x);
                else M = max(M, x + 1);
            }
        }

        cout << M << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3492kb

input:

3
8 13 4 10

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

5
13 12 14 10 14 12

output:

3

result:

ok single line: '3'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

2
2 2 1

output:

3

result:

ok single line: '3'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

1
300172042 474444146

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

1
636357447 557539481

output:

1

result:

ok single line: '1'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

2
139715426 368724097 417561009

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

2
77784868 542697475 509604021

output:

2

result:

ok single line: '2'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

2
698395658 71848686 699775597

output:

1

result:

ok single line: '1'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

2
487635147 571273621 442673389

output:

3

result:

ok single line: '3'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

2
502022170 254766224 258867503

output:

2

result:

ok single line: '2'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

2
783651505 271735448 154090385

output:

3

result:

ok single line: '3'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

3
423187900 701340783 708457090 788989478

output:

0

result:

ok single line: '0'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

3
172068101 507957913 237246316 805323765

output:

2

result:

ok single line: '2'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

3
309846480 218704879 536482379 754210806

output:

1

result:

ok single line: '1'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

3
150235215 485036833 52089968 645641645

output:

3

result:

ok single line: '3'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

3
735389981 669677621 733676260 858050940

output:

2

result:

ok single line: '2'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

3
635103474 551413670 85269704 730878535

output:

3

result:

ok single line: '3'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

3
287528440 314452762 846234936 452787633

output:

1

result:

ok single line: '1'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

3
276069955 969481471 992185356 536479156

output:

2

result:

ok single line: '2'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

3
225096493 88165689 415816372 360778803

output:

1

result:

ok single line: '1'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

3
651934487 760368054 975264908 206290402

output:

3

result:

ok single line: '3'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

3
668819975 16012633 798541220 258404088

output:

2

result:

ok single line: '2'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

3
303955151 276719749 324951113 63908344

output:

3

result:

ok single line: '3'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

3
419862649 709195111 424612582 548104611

output:

3

result:

ok single line: '3'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

3
46436854 762650424 543885894 63420906

output:

3

result:

ok single line: '3'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

3
663885616 817966829 428282021 750799481

output:

3

result:

ok single line: '3'

Test #27:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

3
453815838 784866392 626401113 33629018

output:

3

result:

ok single line: '3'

Test #28:

score: -100
Wrong Answer
time: 0ms
memory: 3812kb

input:

3
612031283 905623341 296446821 317142883

output:

3

result:

wrong answer 1st lines differ - expected: '4', found: '3'