static void Main(string[] args) { // ?? string[] sS = Console.ReadLine().Trim().Split(' '); int iN = int.Parse(sS[0]); sS = Console.ReadLine().Trim().Split(' '); List <int> listT = new List <int>(); for (int i = 0; i < iN; i++) { listT.Add(int.Parse(sS[i])); } sS = Console.ReadLine().Trim().Split(' '); int iM = int.Parse(sS[0]); List <ClsSmp> listM = new List <ClsSmp>(); for (int i = 0; i < iM; i++) { sS = Console.ReadLine().Trim().Split(' '); ClsSmp oneUsr = new ClsSmp(); oneUsr.iP = int.Parse(sS[0]) - 1; oneUsr.iX = int.Parse(sS[1]); listM.Add(oneUsr); } System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); // ?? int iSum = listT.Sum(); for (int i = 0; i < listM.Count; i++) { listM[i].iS = iSum - listT[listM[i].iP] + listM[i].iX; } //?? for (int i = 0; i < listM.Count; i++) { Console.WriteLine("{0}", listM[i].iS.ToString().Trim()); } sw.Stop(); #if DEBUG Console.WriteLine(); Console.WriteLine("{0}", sw.Elapsed.ToString()); Console.WriteLine("?????????????????????"); Console.ReadKey(); #endif }
static void Main(string[] args) { // ?? string[] sInp = Console.ReadLine().Trim().Split(' '); int iN = int.Parse(sInp[0]); int iQ = int.Parse(sInp[1]); List <ClsSmp> lstSmp = new List <ClsSmp>(); for (int i = 0; i < iQ; i++) { sInp = Console.ReadLine().Trim().Split(' '); ClsSmp oneUsr = new ClsSmp(); oneUsr.iL = int.Parse(sInp[0]) - 1; oneUsr.iR = int.Parse(sInp[1]) - 1; oneUsr.iT = int.Parse(sInp[2]); lstSmp.Add(oneUsr); } System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); // ?? List <int> lstOut = new List <int>(); for (int i = 0; i < iN; i++) { lstOut.Add(0); } for (int i = 0; i < lstSmp.Count; i++) { for (int j = lstSmp[i].iL; j <= lstSmp[i].iR; j++) { lstOut[j] = lstSmp[i].iT; } } // ?? for (int i = 0; i < lstOut.Count; i++) { Console.WriteLine("{0}", lstOut[i].ToString()); } sw.Stop(); #if DEBUG Console.WriteLine(); Console.WriteLine("{0}", sw.Elapsed.ToString()); Console.WriteLine("?????????????????????"); Console.ReadKey(); #endif }
static void Main(string[] args) { // ?? List <ClsSmp> lstSmp = new List <ClsSmp>(); for (int j = 0; j < 3; j++) { string sInp = Console.ReadLine().Trim(); ClsSmp oneUsr = new ClsSmp(); oneUsr.iD = j; oneUsr.iP = int.Parse(sInp); lstSmp.Add(oneUsr); } System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); // ?? lstSmp.Sort(delegate(ClsSmp mca1, ClsSmp mca2) { return(mca2.iP - mca1.iP); }); // ?? ??? for (int j = 0; j < lstSmp.Count; j++) { lstSmp[j].iJ = j + 1; } // ?? ??? lstSmp.Sort(delegate(ClsSmp mca1, ClsSmp mca2) { return(mca1.iD - mca2.iD); }); // Index??? // ?? for (int j = 0; j < lstSmp.Count; j++) { Console.WriteLine("{0}", lstSmp[j].iJ.ToString()); } sw.Stop(); #if DEBUG Console.WriteLine(); Console.WriteLine("{0}", sw.Elapsed.ToString()); Console.WriteLine("?????????????????????"); Console.ReadKey(); #endif }
static void Main(string[] args) { // ?? List <ClsSmp> lstSmp = new List <ClsSmp>(); string sS = Console.ReadLine().Trim(); string[] sInp = Console.ReadLine().Trim().Split(' '); int iN = int.Parse(sInp[0]); for (int j = 0; j < iN; j++) { sInp = Console.ReadLine().Trim().Split(' '); ClsSmp oneUsr = new ClsSmp(); oneUsr.iL = int.Parse(sInp[0]); oneUsr.iR = int.Parse(sInp[1]); lstSmp.Add(oneUsr); } System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); // ?? for (int j = 0; j < lstSmp.Count; j++) { sS = ChangeRev(sS, lstSmp[j].iL, lstSmp[j].iR); } // ?? Console.WriteLine("{0}", sS.ToString()); sw.Stop(); #if DEBUG Console.WriteLine(); Console.WriteLine("{0}", sw.Elapsed.ToString()); Console.WriteLine("?????????????????????"); Console.ReadKey(); #endif }
static void Main(string[] args) { // ?? string[] sS = Console.ReadLine().Trim().Split(' '); int iN = int.Parse(sS[0]); int iA = int.Parse(sS[1]); int iB = int.Parse(sS[2]); List <ClsSmp> lstSmp = new List <ClsSmp>(); for (int i = 0; i < iN; i++) { ClsSmp oneUsr = new ClsSmp(); sS = Console.ReadLine().Trim().Split(' '); oneUsr.sS = sS[0]; oneUsr.iD = int.Parse(sS[1]); lstSmp.Add(oneUsr); } System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); // ?? int iNow = 0; for (int i = 0; i < lstSmp.Count; i++) { int iMov = 0; if (lstSmp[i].iD < iA) { iMov = iA; } if (lstSmp[i].iD >= iA && lstSmp[i].iD <= iB) { iMov = lstSmp[i].iD; } if (lstSmp[i].iD > iB) { iMov = iB; } iNow += (lstSmp[i].sS == "West" ? -1 : 1) * iMov; } // ?? string sOut = ""; if (iNow == 0) { } else if (iNow > 0) { sOut = "East "; } else { sOut = "West "; } sOut += Math.Abs(iNow).ToString(); Console.WriteLine("{0}", sOut.ToString()); sw.Stop(); #if DEBUG Console.WriteLine(); Console.WriteLine("{0}", sw.Elapsed.ToString()); Console.WriteLine("?????????????????????"); Console.ReadKey(); #endif }