Submission #139553

# Submission time Handle Problem Language Result Execution time Memory
139553 2019-08-01T02:12:44 Z meatrow Boat (APIO16_boat) C++17
9 / 100
4 ms 504 KB
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;

const int N = 1500;

int dp[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    set<int> pnts;
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
        pnts.insert(a[i].first);
        pnts.insert(a[i].first - 1);
        pnts.insert(a[i].second);
    }
    size_t m = pnts.size();
    vector<int> b(m);
    auto it = pnts.begin();
    for (int& i : b) {
        i = *(it++);
    }
    fill(dp, dp + m, 1);
    for (int i = 0; i < n; i++) {
        int len = a[i].second - a[i].first;
        int a0 = 0;
        ll d = 0;
        for (int j = 0; j < m; j++) {
            int pos = b[j];
            if (pos == a[i].first - 1) {
                a0 = dp[j];
            }
            if (pos == a[i].first) {
                d = dp[j];
            }
            if (pos >= a[i].first ) {
                dp[j] += a0 + d * min(pos - a[i].first, len);
                dp[j] %= mod;
            }
        }
    }
    cout << dp[m - 1] - 1;
    return 0;
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:42:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < m; j++) {
                         ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 4 ms 380 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 3 ms 380 KB Output is correct
9 Correct 4 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 4 ms 380 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 3 ms 380 KB Output is correct
9 Correct 4 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Incorrect 4 ms 504 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 4 ms 380 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 3 ms 380 KB Output is correct
9 Correct 4 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Incorrect 4 ms 504 KB Output isn't correct
22 Halted 0 ms 0 KB -