paste bin
Author
Language
C++
Plain text
Accesslog
Action script
Ada
Apache
Arduino
Armasm
Autohotkey
Awk
Bash
Basic
Brainfuck
C
Clojure
Cmake
C#
css
D
Delphi
Dockerfile
Erlang
Fortran
F#
Gauss
Go
Gradle
Graphql
Groovy
Haskell
Ini
Java
JavaScript
json
Julia
Kotlin
Lasso
LaTeX
Leaf
lisp
llvm
Lua
Makefile
Markdown
Mathematica
Matlab
Nginx
Objective-C
Ocaml
Oxygene
Perl
PgSQL
php
Powershell
Processing
Profile
Properties
Puppet
Purebasic
Python
Q
QML
R
Ruby
Rust
Scala
Scheme
Scilab
Shell
Smalltalk
SQL
Swift
Typescript
VB.NET
VB Script
Verilog
Vim
Wasm
x86asm
Xml
Xquery
Yaml
source code:
#include <cstdio> #include <algorithm> using std::sort; struct tNode { int startTime; int endTime; bool operator<(const tNode &b)const { if(endTime != b.endTime) return endTime<b.endTime; else return startTime<b.startTime; } }; int main(void) { int i,N,currTime,cow; tNode *timeList; while(1) { scanf("%d",&N); if(N==0) break; timeList=new tNode [N]; for(i=0;i<N;i++) scanf("%d%d",&timeList[i].startTime,&timeList[i].endTime); sort(timeList,timeList+N); i=1; currTime=timeList[0].endTime; cow=1; while(i<N) { while(i<N && timeList[i].startTime<currTime) i++; if(i==N) break; cow++; currTime=timeList[i].endTime; } printf("%d\n",cow); delete [] timeList; } return 0; }
comment: