hiho week 108 register

Ended

Participants:295

Verdict:Accepted
Score:100 / 100
Submitted:2016-07-24 12:27:39

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <cstdio>
#include <deque>
#include <algorithm>    
using namespace std;
struct chunk {
    int v, s, e;
};
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    deque<chunk> que;
    int c;
    bool f = true;
    for (int k = 1; k <= n; ++k) {
        if(f) scanf("%d", &c);
        if (que.empty()) {
            que.push_back({ k, 0, c - 1 });
        }
        else {
            bool flag = false;
            int minK = n + 1;
            int idx = -1;
            for (int i = 0; i < que.size(); ++i) {
                if (minK > que[i].v) {
                    minK = que[i].v;
                    idx = i;
                }
                if (i == 0) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX