#include<iostream>
using namespace std;
int low, high, wynik, n,i, j, l, liczba;
const int M=1000000;
bool ans=true;
int pocz[M];
int kon[M];
int main()
{
liczba=1;
cin>>n;
low=0;
high=M;
wynik=0;
for(i=0;i<n;i++)
{
cin>>pocz[i]>>kon[i];
if(pocz[i]>low)
low=pocz[i];
if(kon[i]<high)
high=kon[i];
l++;
if(l>=low && l<=high)
{
l=0;
wynik++;
low=0;
high=M;
}
//cout<<low<<high<<endl;
if(low>high || l>high){
ans=false;
break;
}
}
if(l<low)
ans=false;
if(ans)
cout<<wynik<<" "<<liczba;
else cout<<"NIE";
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include<iostream> using namespace std; int low, high, wynik, n,i, j, l, liczba; const int M=1000000; bool ans=true; int pocz[M]; int kon[M]; int main() { liczba=1; cin>>n; low=0; high=M; wynik=0; for(i=0;i<n;i++) { cin>>pocz[i]>>kon[i]; if(pocz[i]>low) low=pocz[i]; if(kon[i]<high) high=kon[i]; l++; if(l>=low && l<=high) { l=0; wynik++; low=0; high=M; } //cout<<low<<high<<endl; if(low>high || l>high){ ans=false; break; } } if(l<low) ans=false; if(ans) cout<<wynik<<" "<<liczba; else cout<<"NIE"; return 0; } |
English