Cod sursa(job #2887698)
| Utilizator | Data | 10 aprilie 2022 01:19:51 | |
|---|---|---|---|
| Problema | Branza | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <iostream>
#include <fstream>
std::ifstream f("branza.in");
std::ofstream g("branza.out");
struct saptamana{
long long c,p;
};
int main() {
int n,s,t;
long long suma = 0;
f>>n>>s>>t;
saptamana v[n+1];
for(int i = 1; i <= n; i++){
f>>v[i].c>>v[i].p;
}
for(int i = 1; i <= n; i++){
suma = suma + v[i].c*v[i].p;
for(int j = i+1; (j <= n && j <= i+t); j++){
if(v[i].c + (s*(j-i)) <= v[j].c){
suma += ((v[i].c+s*(j-i))*v[j].p);
v[j].p = 0;
}
else j = n+1;
}
}
g<<suma;
return 0;
}
