제출 #758511

#제출 시각아이디문제언어결과실행 시간메모리
758511dzdzxSjeckanje (COCI21_sjeckanje)C++17
0 / 110
2 ms212 KiB
#include<bits/stdc++.h> #define int long long using namespace std; main() { int n,q; cin>>n>>q; int a[n+1]; for (int i=1;i<=n;i++)cin>>a[i]; while (q--){ int l,r,x; cin>>l>>r>>x; for (int i=l;i<=r;i++)a[i]+=x; vector <int> v[n+1]; int ind=1; v[ind].push_back(a[1]); for (int i=2;i<=n;i++){ if (a[i]==a[i-1])ind++; if (i>2){ if (a[i-2]<a[i-1] && a[i-1]>a[i])ind++; if (a[i-2]>a[i-1] && a[i-1]<a[i])ind++; } v[ind].push_back(a[i]); } int ans=0; for (int i=1;i<=n;i++){ if (v[i].size()>0){ ans+=abs(v[i][v[i].size()-1]-v[i][0]); } } cout<<ans<<"\n"; } }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...