UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#206675#3709. roadshawn10069ms1588kbC++539b2024-07-23 19:54:562024-07-23 20:20:11

answer

#include <bits/stdc++.h>
using namespace std;

int n,a[100010],ans,mx=-1,flag;
//bool check(int l,int r){
//	for (int i=0;i<n;i++){
//		if (a[i]!=0)  return 0;
//	}
//	return 1;
//} 
//void dfs(int l,int r){
//	if (flag)  return;
//	if (check()==1){
//		flag=1;
//		return;
//	}
//	step++;
//	int mid=(l+r)/2;
//	dfs();
//	dfs();
//}
int main(){
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
    for(int i=1;i<=n;i++){
        if(a[i]>a[i-1])  ans+=a[i]-a[i-1];
    }
    cout<<ans;
//	cout<<step;
	return 0;
}

详细

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

Test #1:

score: 10
Accepted
time: 0ms
memory: 1200kb

input:

3
3 1 1

output:

3

result:

ok single line: '3'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1204kb

input:

6
6 8 3 2 0 9

output:

17

result:

ok single line: '17'

Test #3:

score: 10
Accepted
time: 0ms
memory: 1204kb

input:

10
7 18 29 0 47 0 41 40 28 7

output:

117

result:

ok single line: '117'

Test #4:

score: 10
Accepted
time: 0ms
memory: 1204kb

input:

20
99 27 61 62 17 79 61 22 13 49 71 61 8 81 67 80 47 83 88 30

output:

381

result:

ok single line: '381'

Test #5:

score: 10
Accepted
time: 0ms
memory: 1204kb

input:

50
12 74 78 33 23 58 83 76 59 77 85 25 18 98 16 100 79 88 36 53 72 95 93 39 78 5 15 56 26 62 65 57 6...

output:

755

result:

ok single line: '755'

Test #6:

score: 10
Accepted
time: 0ms
memory: 1204kb

input:

250
10 907 960 459 737 614 650 664 12 662 983 803 56 704 255 356 966 746 486 719 496 37 891 976 242 ...

output:

44356

result:

ok single line: '44356'

Test #7:

score: 10
Accepted
time: 1ms
memory: 1208kb

input:

1000
198 276 974 388 435 817 424 649 959 180 70 662 283 526 58 973 773 770 981 578 416 566 28 645 23...

output:

163692

result:

ok single line: '163692'

Test #8:

score: 10
Accepted
time: 4ms
memory: 1236kb

input:

10000
756 214 223 686 31 864 369 733 235 623 150 944 691 961 63 753 621 913 534 787 771 344 669 505 ...

output:

1667465

result:

ok single line: '1667465'

Test #9:

score: 10
Accepted
time: 22ms
memory: 1400kb

input:

50000
8376 7573 9441 5255 8061 7257 9681 5433 3130 2350 5791 4395 6264 5621 9138 5434 7483 611 2845 ...

output:

83301706

result:

ok single line: '83301706'

Test #10:

score: 10
Accepted
time: 42ms
memory: 1588kb

input:

100000
4429 7325 4658 8976 1076 9705 2591 5563 8327 2532 3195 98 760 4850 3310 1567 4893 8353 5623 9...

output:

166653075

result:

ok single line: '166653075'