Skip to content

Instantly share code, notes, and snippets.

@s2kw
Created October 21, 2014 17:50
Show Gist options
  • Save s2kw/2a81dbc6b8413ff2f43b to your computer and use it in GitHub Desktop.
Save s2kw/2a81dbc6b8413ff2f43b to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
namespace PlayGrournd
{
class MainClass
{
public static void Main(){
var line = System.Console.ReadLine().Trim();
string[] words = line.Split(' ');
var sheetCount = System.Convert.ToInt32(words[0]);
var length = System.Convert.ToInt32(words[1]);
System.Collections.Generic.List<bool> sheets = new System.Collections.Generic.List<bool>( new bool[sheetCount] ){};
for(int i = 0; i < length; i++ ){
var input2 = System.Console.ReadLine();
var w = input2.Split(' ');
var count = System.Convert.ToInt32(w[0]);
var sheet = System.Convert.ToInt32(w[1]);
//test
bool test = true;
for(int x = 0; x < count; x++ ){
var target = sheet + x -1;
target = target >= sheets.Count ? ( target - sheets.Count ) : target ;
if (sheets [target] == false) {
continue;
} else {
test = false;
break;
}
}
if (test == false)
continue;
//do
for(int x = 0; x < count; x++ ){
var target = sheet + x -1;
target = target >= sheets.Count ? ( target - sheets.Count ) : target ;
sheets [target] = true;
}
// current
//sheets.ForEach( a => System.Console.WriteLine( a ) );
}
//System.Console.WriteLine("");
var c = sheets.Where( d => d == true ).Count();
System.Console.WriteLine( c );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment