# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
715905 | 2023-03-28T11:48:21 Z | ktkerem | 금 캐기 (IZhO14_divide) | C++17 | 58 ms | 9880 KB |
/*#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/ #include<bits/stdc++.h> typedef long long ll; typedef long double ld; typedef __int128 vll; typedef long long ftyp; typedef std::complex<ftyp> vec; #define llll std::pair<ll , ll> #define pb push_back #define fi first #define sec second #define cx real #define cy imag #define all(a) a.begin() , a.end() #define debug std::cout << "!!ALERT ALERT!!" << std::endl; const ll limit = 1e18+7; const ll sus = 1e5+5; std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count()); ll n , m;std::vector<std::pair<ll , llll>> ar; ll mx[sus * 4] , gld[sus]; void sv(ll l , ll r , ll a){ if(l == r){ mx[a] = ar[l].sec.fi; return; } ll md = (l + r)/2; sv(l , md , a*2); sv(md+1 , r , a*2+1); mx[a] = std::max(mx[a*2] , mx[a*2+1]); ll cst = 0 , g = 0; for(ll i = md+1;r>=i;i++){ cst += (ar[i].fi - ar[i-1].fi) - ar[i].sec.sec; g+= ar[i].sec.fi; } gld[md+1] = 0; ll sc = 0; std::vector<llll> rg; for(ll i = md;l <= i;i--){ gld[i] = gld[i+1] + ar[i].sec.fi; sc += (i == md?0:ar[i+1].fi - ar[i].fi) - ar[i].sec.sec; rg.pb({sc , gld[i]}); } std::sort(all(rg)); ll ind = 0; for(ll i = r;md+1<=i;i--){ while(rg.size() > ind && rg[ind].fi + cst <= 0){ mx[a] = std::max(mx[a] , g + rg[ind].sec); ind++; } cst += ar[i].sec.sec; cst -= (ar[i].fi - ar[i-1].fi); g-=ar[i].sec.fi; } } void solve(){ std::cin >> n; ar.resize(n); for(ll i = 0 ; n>i;i++){ std::cin >> ar[i].fi >> ar[i].sec.fi >> ar[i].sec.sec; } sv(0 , n-1 , 1); std::cout << mx[1] << "\n"; return;/**/ } int main(){ std::ios_base::sync_with_stdio(false);std::cin.tie(NULL); ll t = 1; //std::cin >> t; while(t--){ solve(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 308 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 468 KB | Output is correct |
19 | Correct | 1 ms | 388 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 468 KB | Output is correct |
22 | Correct | 2 ms | 480 KB | Output is correct |
23 | Correct | 3 ms | 732 KB | Output is correct |
24 | Correct | 3 ms | 820 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 308 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 468 KB | Output is correct |
19 | Correct | 1 ms | 388 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 468 KB | Output is correct |
22 | Correct | 2 ms | 480 KB | Output is correct |
23 | Correct | 3 ms | 732 KB | Output is correct |
24 | Correct | 3 ms | 820 KB | Output is correct |
25 | Correct | 3 ms | 732 KB | Output is correct |
26 | Correct | 6 ms | 1220 KB | Output is correct |
27 | Correct | 8 ms | 1288 KB | Output is correct |
28 | Correct | 28 ms | 4612 KB | Output is correct |
29 | Correct | 30 ms | 4988 KB | Output is correct |
30 | Correct | 57 ms | 9880 KB | Output is correct |
31 | Correct | 58 ms | 8780 KB | Output is correct |
32 | Correct | 55 ms | 8808 KB | Output is correct |
33 | Correct | 52 ms | 8604 KB | Output is correct |
34 | Correct | 57 ms | 8612 KB | Output is correct |
35 | Correct | 54 ms | 9296 KB | Output is correct |
36 | Correct | 55 ms | 9356 KB | Output is correct |