제출 #749916

#제출 시각아이디문제언어결과실행 시간메모리
749916guagua0407Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
119 ms5640 KiB
//#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const int mxn=2e5+5; ll a[mxn]; int main() {_ int n,q,S,T; cin>>n>>q>>S>>T; for(int i=0;i<=n;i++){ cin>>a[i]; } for(int i=n;i>=1;i--){ a[i]-=a[i-1]; } ll ans=0; for(int i=1;i<=n;i++){ if(a[i]>0){ ans+=1ll*S*a[i]; } else{ ans+=1ll*T*a[i]; } } for(int i=0;i<q;i++){ int l,r,x; cin>>l>>r>>x; if(a[l]>0){ ans-=1ll*S*a[l]; } else{ ans-=1ll*T*a[l]; } a[l]+=x; if(a[l]>0){ ans+=1ll*S*a[l]; } else{ ans+=1ll*T*a[l]; } if(r<n){ if(a[r+1]>0){ ans-=1ll*S*a[r+1]; } else{ ans-=1ll*T*a[r+1]; } a[r+1]-=x; if(a[r+1]>0){ ans+=1ll*S*a[r+1]; } else{ ans+=1ll*T*a[r+1]; } } cout<<-ans<<'\n'; } return 0; } //maybe its multiset not set

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

foehn_phenomena.cpp: In function 'void setIO(std::string)':
foehn_phenomena.cpp:12:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...