Răspuns:
#include <iostream>
using namespace std;
int main(){
int n,x,y,p,i,a[1001],b[1001],o=0,s=0;
cin>>n;
cin>>x;
cin>>y;
cin>>p;
for(i=1;i<=n;i++){
cin>>a[i]>>b[i];
o=o+a[i];
s=s+b[i];
}
if(p==1){
cout<<o<<" "<<s<<" "<<o-s;
}
o=0;
if(p==2){
for(i=1;i<=x;i++)
o=o+a[i];
if(o>y){
cout<<"DA";
}else
cout<<"NU";
}
return 0;
}
Explicație:
date mare ABI