Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
new
#include<bits/stdc++.h> using namespace std; #define mem(A) memset(A,0,sizeof(A)) #define loop(i,a,n) for(i=a;i<n;i++) #define pb push_back #define mkp make_pair #define prq priority_queue #define fir first #define sec second #define all(A) A.begin(),A.end() #define mod 1000000007 typedef long long ll; int main() { //freopen("input.txt", "r", stdin); ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>n; loop(i,0,n) cin>>A[i]; last=0; if(n<3) ans=2*n-1; else { q.push(mkp(A[0],0)); q.push(mkp(A[1],1)); for(i=2;i<n;i++) { a=q.top(); q.pop(); b=q.top(); q.push(a); while(i<n && a.fir+b.fir>=A[i]) { q.push(mkp(A[i],i)); a=q.top(); q.pop(); b=q.top(); q.push(a); i++; } if(i<n && a.fir+b.fir<A[i]) { loop(j=last;j<=a.fir && j<n-2;j++) k+=n-i; } } } }
run
|
edit
|
history
|
help
0
stl_sizeof
Dar
Kalkulator z bajerami
Hacher Cup
Breakfast Function
Dead_Lock
Zadanie Kalkulator z bajerami
major element
BoauthCPP
Precendence of Pointer Indirection Example