Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
hacker
#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); ll n,i,c=0,x,pos,ans=0; pair<ll,ll> a,b,t; priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> q; cin>>n; ll D[100]={0}; ll j,A[100]; loop(i,0,n) cin>>A[i]; q.push(mkp(A[0],0)); q.push(mkp(A[1],1)); q.push(mkp(A[2],2)); a=q.top(); q.pop(); b=q.top(); q.pop(); t=q.top(); q.push(b); q.push(a); i=3; while(a.fir+b.fir<t.fir) { q.pop(); if(i==n) break; q.push(mkp(A[i],i)); a=q.top(); q.pop(); b=q.top(); q.pop(); t=q.top(); q.push(a); q.push(b); i++; } ll last=0; for(;i<n;i++) { a=q.top(); q.pop(); b=q.top(); q.push(a); if(a.fir+b.fir>=A[i]) { c++; } else { loop(j,last,a.sec+1) D[j]=c>0?c--:0; q.pop(); last=a.sec+1; a=q.top(); q.pop(); b=q.top(); q.push(a); while(a.fir+b.fir<A[i]) { D[a.sec]=c>0?c--:0; last=a.sec+1; q.pop(); if(q.size()==2) break; a=q.top(); q.pop(); b=q.top(); q.push(a); } c=2; } q.push(mkp(A[i],i)); } loop(i,last,n-2) D[i]=c--; loop(i,0,n) cout<<D[i]<<endl; }
run
|
edit
|
history
|
help
0
precision and fixed point notation
多态
Memory_test
cppPyBatScoreSOLID
FindMissingNewt
Dar
Dijkstra
Silly circular pointer
XD
PriQTel