QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#124061#6342. Security GuardAdam_GS#12 12ms5220kbC++20830b2023-07-14 05:30:202024-07-04 00:38:55

Judging History

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

  • [2024-07-04 00:38:55]
  • 评测
  • 测评结果:12
  • 用时:12ms
  • 内存:5220kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-14 05:30:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=2e5+7;
ll T[LIM];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m, q;
	cin >> n >> m >> q;
	rep(i, n) cin >> T[i];
	ll ans=0;
	rep(i, n-1) ans+=min(T[i], T[i+1]);
	if(T[0]<=T[1]) {
		int l=0;
		while(l<n-1 && T[l]<=T[l+1]) ++l;
		ans+=T[l]-T[0];
	}
	if(T[n-1]<T[n-2]) {
		int l=n-1;
		while(l>0 && T[l]<T[l-1]) --l;
		ans+=T[l]-T[n-1];
	}
	for(int i=1; i<n-1; ++i) if(T[i-1]>T[i] && T[i]<=T[i+1]) {
		int l1=i;
		while(l1<n-1 && T[l1]<=T[l1+1]) ++l1;
		int l2=i;
		while(l2>0 && T[l2]<T[l2-1]) --l2;
		ans+=max(T[l1], T[l2])-T[i];
	}
	cout << ans << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 12
Accepted

Test #1:

score: 12
Accepted
time: 8ms
memory: 5148kb

input:

200000 199999 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

199999

result:

ok 1 number(s): "199999"

Test #2:

score: 12
Accepted
time: 7ms
memory: 5092kb

input:

200000 199999 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

output:

399998

result:

ok 1 number(s): "399998"

Test #3:

score: 12
Accepted
time: 8ms
memory: 5220kb

input:

200000 199999 0
1 2 1 1 1 2 2 1 2 1 1 2 2 2 2 1 1 2 1 1 1 1 2 2 2 1 1 2 2 1 1 1 2 1 1 2 1 1 1 1 1 1 1 2 1 2 2 1 2 1 1 2 1 2 2 2 2 1 2 2 1 2 1 2 2 2 1 1 1 2 1 1 1 2 2 1 1 1 2 2 2 2 1 1 2 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 1 1 1 2 2 2 1 2 1 1 1 2 1 2 2 2 1 2 1 1 1 1 2 2 1 1 2 1 2 1 2 1 2 ...

output:

299700

result:

ok 1 number(s): "299700"

Test #4:

score: 12
Accepted
time: 6ms
memory: 5148kb

input:

200000 199999 0
2 2 1 2 1 2 2 2 1 1 2 2 1 2 1 2 1 1 2 2 2 2 1 1 2 2 2 1 1 1 1 1 2 2 1 2 2 2 2 1 2 1 2 2 1 1 2 1 1 2 2 2 1 1 2 2 2 2 2 2 2 2 1 2 2 2 1 2 2 2 2 2 2 2 1 1 1 2 1 1 1 1 2 1 1 1 2 2 2 2 1 2 2 2 1 1 1 2 1 2 2 1 2 1 1 1 1 2 1 1 1 1 1 2 1 2 1 2 2 2 2 2 1 2 2 1 2 1 2 1 1 2 1 2 2 1 2 2 1 2 1 1 ...

output:

300131

result:

ok 1 number(s): "300131"

Test #5:

score: 12
Accepted
time: 8ms
memory: 5096kb

input:

200000 199999 0
1 2 2 1 1 1 1 2 2 1 2 2 1 2 1 1 1 1 2 1 1 2 1 1 1 1 2 1 1 1 1 2 2 2 1 2 1 1 2 1 2 2 1 1 2 2 2 2 1 2 1 2 2 1 1 1 2 1 1 2 1 1 2 2 1 2 2 2 2 2 1 2 2 2 1 2 2 1 1 2 2 2 1 2 2 2 1 1 2 1 2 2 2 1 2 2 1 2 1 1 2 1 2 2 2 1 2 1 1 1 1 2 1 1 1 2 1 2 2 2 1 2 2 1 2 1 1 1 1 1 2 1 1 2 1 2 1 1 2 2 2 2 ...

output:

300132

result:

ok 1 number(s): "300132"

Test #6:

score: 12
Accepted
time: 8ms
memory: 5156kb

input:

200000 199999 0
2 1 1 2 2 2 1 1 2 2 1 2 2 2 1 1 1 2 1 2 2 1 1 1 1 2 1 2 1 1 1 1 2 2 1 1 1 1 2 1 2 2 2 2 1 1 1 1 2 2 2 1 1 2 2 2 1 2 2 2 1 1 1 1 1 1 1 2 2 2 2 1 2 2 1 2 1 1 1 2 2 1 2 2 1 1 1 2 2 2 2 2 2 2 2 1 1 2 1 2 2 1 2 1 2 1 1 1 1 2 1 1 2 2 2 2 1 1 1 2 1 2 1 1 1 1 2 1 1 1 1 1 1 2 1 2 1 2 1 2 1 1 ...

output:

300094

result:

ok 1 number(s): "300094"

Test #7:

score: 12
Accepted
time: 1ms
memory: 3668kb

input:

2 1 0
2 1
1 2

output:

2

result:

ok 1 number(s): "2"

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #8:

score: 0
Wrong Answer
time: 12ms
memory: 5152kb

input:

200000 199999 0
888688136 635144878 255996991 457498818 501986248 161166265 760280211 255673948 435333678 521749421 41382586 784453705 702026010 746126 770719498 150796793 890458633 167539898 952822340 613539963 472897894 866040523 778440023 870323479 702145156 736556675 190255428 993487185 74569854...

output:

106912151856788

result:

wrong answer 1st numbers differ - expected: '99991732542677', found: '106912151856788'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Wrong Answer

Test #85:

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

input:

16 15 200000
692461146 622302385 805066691 422290641 600839873 940930580 873147413 489653843 239129952 383473127 21389393 913787109 856138328 859082963 262475462 327598064
6 13
6 9
6 15
6 14
6 16
6 8
5 6
1 6
4 6
3 6
6 11
6 7
6 10
2 6
6 12

output:

9760952322

result:

wrong answer 1st numbers differ - expected: '14113958700', found: '9760952322'

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%