Submission #1001816

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10018162024-06-19 07:53:22vjudge1Liteh and Newfiteh (INOI20_litehfiteh)C++17
30 / 100
2059 ms1604 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
map<pair<pair<int,int>,int>,int> mp;
int lg[N], n, a[N];
long long cnt=0;
int calc(int l, int r, int dec=0) {
cnt++;
if(mp.find({{l, r}, dec}) != mp.end()) {
return mp[{{l,r},dec}];
}
if(lg[r-l+1] == 0)return -1;
if(l == r) {
if(a[l]-dec > 1)return -1;
return a[l]-dec;
}
int mn = 1e9;
for(int i = l;i<=r;i++) {
mn=min(mn, a[i]-dec);
}
mn = (mn>0);
int mid = (l+r)/2;
long long L = calc(l, mid, dec+mn);
long long R = calc(mid+1, r, dec+mn);
if(L == -1 or R==-1)return -1;
return mp[{{l,r},dec}]=L+R+mn;
}
int main () {
{
int cntlg=1;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...