Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //B8_b2_Soát vé
- #include<iostream>
- #include<fstream>
- using namespace std;
- ifstream fi("input.inp");
- ofstream fo("output.out");
- struct khach{
- int len;
- int xuong;
- };
- khach *a;
- int n, k, maxexit = 0, minexit = 0;
- void nhap(){
- fi >> n >> k;
- a = new khach[n];
- for(int i = 0; i < n; i++) fi >> a[i].len >> a[i].xuong;
- }
- void xuly(){
- int chua_soat = 0;
- for(int i = 0; i < n; i++){
- if(chua_soat >= a[i].xuong){
- maxexit = maxexit + a[i].xuong;
- chua_soat = chua_soat - a[i].xuong;
- }
- else{
- maxexit = maxexit + chua_soat;
- minexit = minexit + a [i].xuong - chua_soat;
- chua_soat = 0;
- }
- if(i % k == 0){
- chua_soat = 0;
- }
- else{
- chua_soat = chua_soat + a[i].len;
- }
- }
- }
- int main(){
- nhap();
- xuly();
- fo <<minexit << " " <<maxexit;
- delete []a;
- fi.close();
- fo.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement