제출 #145169

#제출 시각아이디문제언어결과실행 시간메모리
145169gs18103코알라 (JOI13_koala)C++14
70 / 100
319 ms14736 KiB
#include <bits/stdc++.h> #define fi first #define se second #define LINF 1000000000000000000LL #define eb emplace_back #define all(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef pair <ll, ll> pll; int t[101010]; ll b[101010], tree[808080], lazy[808080]; void update_lazy(int node, int s, int e) { tree[node] = max(lazy[node], tree[node]); if(s != e) { lazy[node*2] = max(lazy[node*2], lazy[node]); lazy[node*2+1] = max(lazy[node*2+1], lazy[node]); } lazy[node] = -LINF; } void update_range(int node, int s, int e, int l, int r, ll val) { update_lazy(node, s, e); if(s > r || e < l) return; if(s >= l && e <= r) { tree[node] = max(tree[node], val); lazy[node*2] = max(lazy[node*2], val); lazy[node*2+1] = max(lazy[node*2+1], val); return; } int m = (s + e) / 2; update_range(node*2, s, m, l, r, val); update_range(node*2+1, m+1, e, l, r, val); tree[node] = max(tree[node*2], tree[node*2+1]); } ll cal(int node, int s, int e, int l, int r) { update_lazy(node, s, e); if(s > r || e < l) return -LINF; if(s >= l && e <= r) return tree[node]; int m = (s + e) / 2; return max(cal(node*2, s, m, l, r), cal(node*2+1, m+1, e, l, r)); } vector <int> num; int main() { int K, m, d, n; ll a; cin >> K >> m >> d >> a >> n; for(int i = 1; i <= n; i++) { cin >> t[i] >> b[i]; t[i] -= K; num.eb(t[i]%d); } num.eb((m-K)%d); sort(all(num)); num.erase(unique(all(num)), num.end()); for(int i = 0; i < 808080; i++) { lazy[i] = -LINF; tree[i] = -LINF; } update_range(1, 0, num.size()-1, 0, 0, 0LL); update_range(1, 0, num.size()-1, 1, num.size()-1, -a); for(int i = 1; i <= n; i++) { int k = lower_bound(all(num), t[i]%d) - num.begin(); ll val = cal(1, 0, num.size()-1, k, k) + b[i]; update_range(1, 0, num.size()-1, 0, k, val); if(k < num.size()-1) update_range(1, 0, num.size()-1, k+1, num.size()-1, val - a); } int k = lower_bound(all(num), (m-K)%d) - num.begin(); cout << cal(1, 0, num.size()-1, k, k) - a * ((ll)(m - K) / d); }

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

koala.cpp: In function 'int main()':
koala.cpp:71:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(k < num.size()-1) update_range(1, 0, num.size()-1, k+1, num.size()-1, val - a);
      ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...