Codeforces Round #232 (Div. 2), problem: (A) On Segment's Own Points solution: http://ideone.com/WJ0C5y
#include <iostream> #include <cstdio> #include <cstring> using namespace std; int main() { int n, l, r, a, b, arr[110], cnt, flag; scanf("%d", &n); scanf("%d%d", &a, &b); cnt=flag=0; memset(arr, 0, sizeof(arr)); for(int i=a; i<b; i++) arr[i]++; for(int i=1; i<n; i++) { scanf("%d%d", &l, &r); for(int j=l; j<r; j++) arr[j]++; } for(int i=a; i<b; i++) { if(arr[i]==1) cnt++; } printf("%d\n", cnt); return 0; }
No comments:
Post a Comment