제출 #160303

#제출 시각아이디문제언어결과실행 시간메모리
16030312tqianFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
727 ms13304 KiB
#pragma GCC optimize ("O3") #pragma GCC optimize ("Ofast") #include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; const double PI = 4 * atan(1); #define sz(x) (int)(x).size() #define ll long long #define ld long double #define mp make_pair #define pb push_back #define eb emplace_back #define pii pair <int, int> #define vi vector<int> #define f first #define s second #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define vpi vector<pair<int, int>> #define vpd vector<pair<double, double>> #define pd pair<double, double> #define f0r(i,a) for(int i=0;i<a;i++) #define f1r(i,a,b) for(int i=a;i<b;i++) #define trav(a, x) for (auto& a : x) template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; } template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) { cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]"; } void fast_io(){ ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } void io(string taskname){ string fin = taskname + ".in"; string fout = taskname + ".out"; const char* FIN = fin.c_str(); const char* FOUT = fout.c_str(); freopen(FIN, "r", stdin); freopen(FOUT, "w", stdout); fast_io(); } const int MAX = 2e5 + 5; ll a[MAX]; ll diff[MAX]; int main(){ fast_io(); ll n, q, s, t; cin >> n >> q >> s >> t; f0r(i, n+1){ cin >> a[i]; if(i != 0) diff[i] = a[i] - a[i-1]; } ll ans = 0; f0r(i, n){ if(a[i] < a[i+1]){ ans -= s*(a[i+1] - a[i]); } else{ ans += t*(a[i] - a[i+1]); } } while(q--){ int l, r, x; cin >> l >> r >> x; ll d1 = diff[l]; ll d2 = diff[r+1]; if(l != 0){ diff[l] += x; } diff[r+1] -= x; if(l != 0){ if(d1>0){ ans += s*(d1); } else{ ans += t*(d1); } if(d1+x>0){ ans -= s*(d1+x); } else{ ans -= t*(d1+x); } } if(r != n){ if(d2>0){ ans += s*(d2); } else{ ans += t*(d2); } if(d2-x>0){ ans -= s*(d2-x); } else{ ans -= t*(d2-x); } } cout << ans << endl; } return 0; }

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

foehn_phenomena.cpp: In function 'void io(std::__cxx11::string)':
foehn_phenomena.cpp:49:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen(FIN, "r", stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:50:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen(FOUT, "w", stdout);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...