Submission #59781

# Submission time Handle Problem Language Result Execution time Memory
59781 2018-07-23T05:57:09 Z 강태규(#1723) Sparklers (JOI17_sparklers) C++11
0 / 100
10 ms 852 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n, k, t;
int x[100001];
int dp[1001][1001];

const int inf = 1e9 + 7;
llong a[100001];
int check(int s) {
    for (int i = 1; i <= n; ++i) {
        a[i] = 2ll * i * t * s - x[i];
    }
    dp[k][k] = 1;
    for (int l = 1; l < n; ++l) {
        for (int i = 1; i + l <= n; ++i) {
            dp[i][i + l] = 0;
            if (a[i] <= a[i + l]) {
                if (dp[i + 1][i + l] || dp[i][i + l - 1])
                    dp[i][i + l] = 1;
            }
        }
    }
    return dp[1][n];
}

int main() {
    scanf("%d%d%d", &n, &k, &t);
    if (n > 2000) return 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", x + i);
    }
    
    int s = 1, e = inf / t + 1;
    while (s < e) {
        int m = (s + e) / 2;
        if (check(m)) e = m;
        else s = m + 1;
    }
    printf("%d\n", s);
	return 0;
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &k, &t);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:48:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", x + i);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 3 ms 464 KB Output is correct
5 Correct 4 ms 596 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 3 ms 636 KB Output is correct
10 Correct 10 ms 688 KB Output is correct
11 Correct 4 ms 692 KB Output is correct
12 Correct 5 ms 824 KB Output is correct
13 Correct 3 ms 824 KB Output is correct
14 Correct 3 ms 824 KB Output is correct
15 Correct 3 ms 824 KB Output is correct
16 Correct 3 ms 824 KB Output is correct
17 Correct 3 ms 824 KB Output is correct
18 Correct 3 ms 852 KB Output is correct
19 Incorrect 3 ms 852 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 3 ms 464 KB Output is correct
5 Correct 4 ms 596 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 3 ms 636 KB Output is correct
10 Correct 10 ms 688 KB Output is correct
11 Correct 4 ms 692 KB Output is correct
12 Correct 5 ms 824 KB Output is correct
13 Correct 3 ms 824 KB Output is correct
14 Correct 3 ms 824 KB Output is correct
15 Correct 3 ms 824 KB Output is correct
16 Correct 3 ms 824 KB Output is correct
17 Correct 3 ms 824 KB Output is correct
18 Correct 3 ms 852 KB Output is correct
19 Incorrect 3 ms 852 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 3 ms 464 KB Output is correct
5 Correct 4 ms 596 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 3 ms 636 KB Output is correct
10 Correct 10 ms 688 KB Output is correct
11 Correct 4 ms 692 KB Output is correct
12 Correct 5 ms 824 KB Output is correct
13 Correct 3 ms 824 KB Output is correct
14 Correct 3 ms 824 KB Output is correct
15 Correct 3 ms 824 KB Output is correct
16 Correct 3 ms 824 KB Output is correct
17 Correct 3 ms 824 KB Output is correct
18 Correct 3 ms 852 KB Output is correct
19 Incorrect 3 ms 852 KB Output isn't correct
20 Halted 0 ms 0 KB -