제출 #1296375

#제출 시각아이디문제언어결과실행 시간메모리
1296375qweqerSjeckanje (COCI21_sjeckanje)C++20
110 / 110
566 ms29492 KiB
#include <bits/stdc++.h> #define FOR(i, beg, ed, etr) for(ll i = beg;i <= ed;i += etr) #define FORN(i, beg, ed, etr) for(ll i = beg;i >= ed;i -= etr) #define all(x) x.begin(), x.end() #define F first #define pb push_back #define S second #define con continue using namespace std; typedef long long ll; typedef pair<ll,ll> pii; typedef pair<ll,ll> pll; typedef double db; typedef long double ld; const ll inf = 1e9; const ll INF = 1e18; const ll N = 2e5 + 5; const ll MOD = 1e9 + 7; struct node{ ll dp[2][2] = {0,0,0,0}; ll br[2] = {0,0}; }; node null{0,0,0,0,0,0}; ll a[N]; ll n; node merge(node z,node x){ node p = null; p.br[0] = z.br[0]; p.br[1] = x.br[1]; FOR(w, 0, 15, 1){ ll l = (w & 1ll); ll s = ((w >> 1ll) & 1ll); ll t = ((w >> 2ll) & 1ll); ll r = ((w >> 3ll) & 1ll); if(s && t){ if(z.br[1] * x.br[0] > 0){ p.dp[l][r] = max(p.dp[l][r],z.dp[l][s] + x.dp[t][r]); } } else{ p.dp[l][r] = max(p.dp[l][r],z.dp[l][s] + x.dp[t][r]); } } return p; } node t[4 * N]; void upd(int pos,ll x, int v = 1,int l = 1,int r =n){ if(l == r){ t[v].br[0] += x; t[v].br[1] += x; t[v].dp[1][1] = abs(t[v].br[1]); return; } ll mid = (l + r) / 2; if(pos <= mid)upd(pos,x,v+v,l,mid); else upd(pos,x,v+v+1,mid+1,r); t[v] = merge(t[v+v],t[v+v+1]); } void solve(){ int q;cin >>n >> q; FOR(i, 1, n, 1){ cin >> a[i]; if(i>1){ upd(i-1,a[i] - a[i-1]); } } while(q--){ ll l,r,x;cin >> l >> r >> x; if(l > 1)upd(l-1,x); if(r < n)upd(r,-x); cout << t[1].dp[1][1] << '\n'; } } main(){ ios_base::sync_with_stdio(0); cin.tie(0); // freopen("cardgame.in","r",stdin); // freopen("cardgame.out","w",stdout); ll abd = 1; // cin >> abd; FOR(i, 1, abd, 1){ solve(); } }

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

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