제출 #1039972

#제출 시각아이디문제언어결과실행 시간메모리
1039972khanhtbFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
88 ms13284 KiB
#pragma GCC optimize("Ofast,unroll-loops") #include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define ld long double #define pb push_back #define pf push_front #define vi vector<ll> #define vii vector<vi> #define pll pair<ll, ll> #define vpll vector<pll> #define all(a) a.begin(), a.end() #define fi first #define se second using namespace std; const ll mod = 998244353; const ll inf = 1e18; const ll blocksz = 320; const ll N = 2e5+8; ll a[N],d[N],s,t; int n,q; ll ans = 0; void update(int i, int x){ if(i > n) return; if(d[i] > 0) ans -= d[i]*s*x; else ans -= d[i]*t*x; } void solve(){ cin >> n >> q >> s >> t; for(int i = 0; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++){ d[i] = a[i]-a[i-1]; update(i,1); } while(q--){ int l,r,x;cin >> l >> r >> x; update(l,-1); update(r+1,-1); d[l] += x; d[r+1] -= x; update(l,1); update(r+1,1); cout << ans << '\n'; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("test.inp", "r")) { freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } int T = 1; // cin >> T; for (int i = 1; i <= T; i++) { solve(); cout << '\n'; } }

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:51:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:52:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         freopen("test.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...