#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int n,m,q;cin>>n>>m>>q;
int ans = 0;
int ans2=0;
int arr[n];
for(int i=0;i<n;i++) cin>>arr[i];
for(int i=0;i<n-1;i++){
ans2+=max(arr[i],arr[i+1]);
}
int k = unique(arr,arr+n)-arr;
for(int i=0;i<k-2;i++) {
if(arr[i]>arr[i+1] && arr[i+1]<arr[i+2]){
ans2-=min(arr[i],arr[i+2]);
ans2+=arr[i+1];
}
}
for(int i=0;i<m;i++){
int u,v;cin>>u>>v;
}
cout<<ans2<<"\n";
return 0;
}
Compilation message
guard.cpp: In function 'int main()':
guard.cpp:13:6: warning: unused variable 'ans' [-Wunused-variable]
13 | int ans = 0;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
30 ms |
1116 KB |
Output is correct |
3 |
Correct |
30 ms |
1212 KB |
Output is correct |
4 |
Correct |
31 ms |
1116 KB |
Output is correct |
5 |
Correct |
31 ms |
1116 KB |
Output is correct |
6 |
Correct |
30 ms |
1112 KB |
Output is correct |
7 |
Correct |
31 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
30 ms |
1116 KB |
Output is correct |
3 |
Correct |
30 ms |
1212 KB |
Output is correct |
4 |
Correct |
31 ms |
1116 KB |
Output is correct |
5 |
Correct |
31 ms |
1116 KB |
Output is correct |
6 |
Correct |
30 ms |
1112 KB |
Output is correct |
7 |
Correct |
31 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Incorrect |
37 ms |
1232 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
30 ms |
1116 KB |
Output is correct |
3 |
Correct |
30 ms |
1212 KB |
Output is correct |
4 |
Correct |
31 ms |
1116 KB |
Output is correct |
5 |
Correct |
31 ms |
1116 KB |
Output is correct |
6 |
Correct |
30 ms |
1112 KB |
Output is correct |
7 |
Correct |
31 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Incorrect |
37 ms |
1232 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
30 ms |
1116 KB |
Output is correct |
3 |
Correct |
30 ms |
1212 KB |
Output is correct |
4 |
Correct |
31 ms |
1116 KB |
Output is correct |
5 |
Correct |
31 ms |
1116 KB |
Output is correct |
6 |
Correct |
30 ms |
1112 KB |
Output is correct |
7 |
Correct |
31 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Incorrect |
37 ms |
1232 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
30 ms |
1116 KB |
Output is correct |
3 |
Correct |
30 ms |
1212 KB |
Output is correct |
4 |
Correct |
31 ms |
1116 KB |
Output is correct |
5 |
Correct |
31 ms |
1116 KB |
Output is correct |
6 |
Correct |
30 ms |
1112 KB |
Output is correct |
7 |
Correct |
31 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Incorrect |
37 ms |
1232 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |