Submission #879080

#TimeUsernameProblemLanguageResultExecution timeMemory
879080willychanSecurity Guard (JOI23_guard)C++17
12 / 100
39 ms5564 KiB
#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(abs(arr[i]-arr[i+1]),abs(arr[i+1]-arr[i+2])); for(int i=0;i<m;i++){ int u,v;cin>>u>>v; } cout<<ans2<<"\n"; return 0; }

Compilation message (stderr)

guard.cpp: In function 'int main()':
guard.cpp:13:6: warning: unused variable 'ans' [-Wunused-variable]
   13 |  int ans = 0;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...