CF GYM 100703B Energy Saving

Source: Internet
Author: User

Test instructions: The Prince buys M bulbs a month for n rooms for light bulbs, if the current number of light bulbs is enough to change the first room of the list, until the bulb is not enough, to give a query, query x months has changed several houses, the number of light bulbs left in hand.

Solution: Water problem ... Small simulations.

Code:

#include <stdio.h> #include <iostream> #include <algorithm> #include <string> #include < string.h> #include <math.h> #include <limits.h> #include <time.h> #include <stdlib.h># include<map> #include <queue> #include <set> #include <stack> #include <vector> #define LL    Long longusing namespace Std;int a[1005], Ans[100005][2];int main () {int n, m;        while (~SCANF ("%d%d", &n, &m)) {int cnt = 0;        for (int i = 0; i < n; i++) {scanf ("%d", &a[i]);        } Ans[0][0] = 0, ans[0][1] = 0;        int j = 0;            for (int i = 1; I <= 100000; i++) {cnt++;            Ans[i][0] = ans[i-1][0];            ANS[I][1] = ans[i-1][1] + m;                while (J < n && A[j] <= ans[i][1]) {ans[i][0]++;                ANS[I][1]-= a[j];            j + +;        } if (j = = n) break; } int q;       scanf ("%d", &q);            while (q--) {int x;            scanf ("%d", &x);            if (x > CNT) x = CNT;        printf ("%d%d\n", ans[x][0], ans[x][1]); }} return 0;}

  

CF GYM 100703B Energy Saving

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.