제출 #364998

#제출 시각아이디문제언어결과실행 시간메모리
364998farhan132Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
133 ms9068 KiB
/***Farhan132***/ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double dd; typedef vector<ll> vll; typedef pair<ll , ll> ii; typedef vector< ii > vi; typedef pair < pair < ll , ll > , pair < ll , ll > > cm; #define ff first #define ss second #define pb push_back #define in insert #define f0(b) for(int i=0;i<(b);i++) #define f00(b) for(int j=0;j<(b);j++) #define f1(b) for(int i=1;i<=(b);i++) #define f11(b) for(int j=1;j<=(b);j++) #define f2(a,b) for(int i=(a);i<=(b);i++) #define f22(a,b) for(int j=(a);j<=(b);j++) #define sf(a) scanf("%lld",&a) #define sff(a,b) scanf("%lld %lld", &a , &b) #define pf(a) printf("%lld\n",a) #define pff(a,b) printf("%lld %lld\n", a , b) #define PI 3.14159265359 #define bug printf("**!\n") #define mem(a , b) memset(a, b ,sizeof(a)) #define front_zero(n) __builtin_clzll(n) #define back_zero(n) __builtin_ctzll(n) #define total_one(n) __builtin_popcountll(n) #define clean fflush(stdout) const ll mod = (ll)1e9 + 7; const ll maxn = (ll)2e5 + 5; const int nnn = 1048590; const int inf = numeric_limits<int>::max()-1; //const ll INF = numeric_limits<ll>::max()-1; //const ll INF = 1e18; ll dx[]={0,1,0,-1}; ll dy[]={1,0,-1,0}; ll dxx[]={0,1,0,-1,1,1,-1,-1}; ll dyy[]={1,0,-1,0,1,-1,1,-1}; void solve(){ ll n , q , s , t; cin >> n >> q >> s >> t; ll d[n+5] , a[n+5]; f0(n+1) cin >> a[i]; ll cur = 0; for(ll i = 1; i <= n; i++){ d[i] = a[i] - a[i-1]; if(a[i] > a[i-1]) cur -= (a[i] - a[i-1]) * s; else cur += (a[i-1] - a[i]) * t; } while(q--){ ll l , r , x; cin >> l >> r >> x; ll sv = cur; if(d[l] > 0) cur += s * abs(d[l]); else cur -= t * abs(d[l]); d[l] += x; if(d[l] > 0) cur -= abs(d[l]) * s; else cur += abs(d[l]) * t; if(r+1 <= n){ r++; if(d[r] > 0) cur += s * abs(d[r]); else cur -= t * abs(d[r]); d[r] -= x; if(d[r] > 0) cur -= abs(d[r]) * s; else cur += abs(d[r]) * t; } cout << cur << '\n'; } return; } int main() { #ifdef LOCAL freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #else // freopen("cbarn2.in", "r", stdin); // freopen("cbarn2.out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); #endif //cout << fixed << setprecision(10); // work(maxn); // mem(b,0); ll T; T=1; //cin >> T; //scanf("%lld",&T); // ll CT = 0; //work(); while(T--){ //cout << "Case " << ++CT <<": " ; //printf("Case %lld: ",++CT); solve(); } return 0; }

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

foehn_phenomena.cpp: In function 'void solve()':
foehn_phenomena.cpp:66:12: warning: unused variable 'sv' [-Wunused-variable]
   66 |         ll sv = cur;
      |            ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...