Example #1
0
    static void Main()
    {
        Sc  sc = new Sc();
        int n  = sc.I;
        St2 st = new St2(1, 200000);
        var sb = new StringBuilder();

        for (int i = 0; i < n; i++)
        {
            int[] q = sc.Ia;
            if (q[0] == 1)
            {
                st.Ud(q[1], 1);
            }
            else
            {
                int lb = 0, ub = 200000, mid = 0;
                while (ub - lb > 1)
                {
                    mid = (ub + lb) / 2;
                    if (st.Get(1, mid) > q[1] - 1)
                    {
                        ub = mid;
                    }
                    else
                    {
                        lb = mid;
                    }
                }
                sb.Append(ub + "\n");
                st.Ud(ub, -1);
            }
        }
        Console.Write(sb);
    }
Example #2
0
    static void Main()
    {
        Sc sc = new Sc();

        int[]   s = sc.Ia;
        int[][] a = new int[s[0]][];
        for (int i = 0; i < s[0]; i++)
        {
            a[i] = sc.Ia;
        }
        Array.Sort(a, (u, v) => (u[1] - u[0]) - (v[1] - v[0]));
        St2           st = new St2(1, s[1]);
        StringBuilder sb = new StringBuilder();

        for (int i = 1, j = 0; i <= s[1]; i++)
        {
            while (j < s[0] && a[j][1] - a[j][0] < i)
            {
                if (a[j][1] == a[j][0])
                {
                    st.Ud(a[j][0], 1);
                }
                else
                {
                    st.Ud2(a[j][0], a[j][1], 1);
                }
                j++;
            }
            long ans = s[0] - j;
            for (int k = 0; k <= s[1]; k += i)
            {
                ans += st.Get(k, k);
            }
            sb.Append(ans + "\n");
        }
        Console.Write(sb);
    }
        private void button1_Click(object sender, EventArgs e)
        {
            //try
            //{
            DialogResult dl = MessageBox.Show("ທ່ານຕ້ອງການບັນທຶກຫຼືບໍ?", "ຢືນຢັນ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dl == DialogResult.Yes)
            {
                if (dgvImport.Rows.Count < 1)
                {
                    ms.Check_DataEmpty();
                    return;
                }
                DataSet current_St = new DataSet();
                current_St = cntrl_import.check_orderStatus(cbOrderBill.Text);
                String st = current_St.Tables[0].Rows[0]["OrderStatus"].ToString();
                if (st == St2)
                {
                    return;
                }
                if (st == St1)
                {
                    DataTable d = new DataTable();
                    d = cntrl_import.check_current(cbOrderBill.Text);
                    if (d.Rows.Count > 0)
                    {
                        return;
                    }
                    cntrl_import.Save_importProduct(cbOrderBill.Text, txtdate.Text, LoginController.userlogined.Rows[0]["EmpID"].ToString());
                    cntrl_import.Update_OrderProduct_Status(St2.ToString(), cbOrderBill.Text);
                    for (int i = 0; i < dgvImport.Rows.Count; i++)
                    {
                        String id    = dgvImport.Rows[i].Cells[2].Value.ToString();
                        String Price = dgvImport.Rows[i].Cells[7].Value.ToString();
                        String qty   = dgvImport.Rows[i].Cells[8].Value.ToString();
                        String total = dgvImport.Rows[i].Cells[9].Value.ToString();
                        cntrl_import.Save_importDetail(id.ToString().Trim(), Price.Trim().ToString(), qty.Trim().ToString(), cbOrderBill.Text, total.Trim().ToString());
                    }
                    for (int up = 0; up < dgvImport.Rows.Count; up++)
                    {
                        String    upProid  = dgvImport.Rows[up].Cells[2].Value.ToString();
                        int       upProqty = int.Parse(dgvImport.Rows[up].Cells[8].Value.ToString());
                        DataTable current  = new DataTable();
                        current = cntrl_import.plus_qty(upProid);
                        int stock = int.Parse(current.Rows[0]["Qty"].ToString());
                        int sum   = 0;
                        sum = int.Parse(stock.ToString()) + int.Parse(upProqty.ToString());
                        cntrl_import.Update_Product(sum.ToString(), upProid.ToString());
                    }
                }
                ms.INSERT_Or_SAVE_Successfull();
                dgvImport.DataSource = new DataTable();;
                textBox3.Text        = dgvImport.Rows.Count.ToString();
                label5.Text          = "0.000";
            }
            else
            {
                return;
            }
            //}
            //catch(Exception ex) { MessageBox.Show(ex.Message); }
        }
 static void Main(string[] args)
 {
     St1 x = (St1)StructFactory.Default[1];
     St2 y = (St2)StructFactory.Default[2];
 }