Submission #496072

# Submission time Handle Problem Language Result Execution time Memory
496072 2021-12-20T14:07:39 Z khoabright Remittance (JOI19_remittance) C++17
0 / 100
1 ms 332 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define rep(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define rep1(i, a, b) for (int i = (int)a; i >= (int)b; --i)
#define all(x) x.begin(), x.end()
#define sp(x) setprecision(x) << fixed
typedef long double db;

const int N = 1e6 + 5;
const int inf = 1e9;
pair<db, db> f[N];
db ans[N];

bool solve() {
    int n; cin >> n;
    vector<db> a(n + 1), b(n + 1);
    rep(i, 1, n) cin >> a[i] >> b[i];

    f[1] = {0.5, (a[1] - b[1]) / 2};
    rep(i, 2, n - 1) {
        f[i] = {f[i - 1].ff / 2, f[i - 1].ss / 2 + (a[i] - b[i]) / 2};
    }

    // f[n-1] = ax + b
    pair<db, db> tmp = {2, b[n] - a[n]}; // cx + d
    // x = (d - b) / (a - c)
    assert(f[n - 1].ff != tmp.ff);
    ans[n] = (tmp.ss - f[n - 1].ss) / (f[n - 1].ff - tmp.ff);

//    cout<<"ax+b="<<sp(4)<<f[n-1].ff<<' '<<f[n-1].ss<<'\n';
//    cout<<"cx+d="<<sp(4)<<tmp.ff<<' '<<tmp.ss<<'\n';
//
//    cout<<"ans[n]=" << sp(6)<<ans[n]<<'\n';
    if (ans[n] < 0 || (int)ans[n] < ans[n]) return false;
    rep(i, 1, n - 1) {
        ans[i] = f[i].ff * ans[n] + f[i].ss;
        if (ans[i] < 0 || (int)ans[i] < ans[i]) return false;
    }
    return true;
}

main() {
    ios_base::sync_with_stdio(0); cin.tie(0);

    cout << (solve() ? "Yes" : "No");
}

Compilation message

remittance.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   49 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 320 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Incorrect 1 ms 332 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 320 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Incorrect 1 ms 332 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 320 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Incorrect 1 ms 332 KB Output isn't correct
21 Halted 0 ms 0 KB -