Cod sursa(job #2213114)
Utilizator | Data | 15 iunie 2018 17:17:14 | |
---|---|---|---|
Problema | Branza | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.27 kb |
#include <fstream>
std::ifstream f("branza.in");std::ofstream g("branza.out");long long n,s,t,v[100003],d[100003],p=1,q,c,r,i;int main(){f>>n>>s>>t;for(;i<n;++i){f>>v[i]>>c;while(s*(i-d[q])+v[d[q]]>=v[i]&&p<=q)--q;d[++q]=i;if(i-d[p]>t)++p;r+=c*(s*(i-d[p])+v[d[p]]);}g<<r;}