QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#55189#3749. Use FFThyx000AC ✓149ms11400kbC++171.5kb2022-10-12 17:32:502022-10-12 17:32:51

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-12 17:32:51]
  • Judged
  • Verdict: AC
  • Time: 149ms
  • Memory: 11400kb
  • [2022-10-12 17:32:50]
  • Submitted

answer

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

#define int long long
#define x first
#define y second
#define ps push_back
#define endl '\n'

#define kd                     \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.tie(0);
using namespace std;
typedef pair<int, int> pi;
const int N = 2e6 + 100, mod = 1e9 + 7, INF = 1e10;
int lowbit(int x) { return x & -x; }
int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); }

int a[N], b[N];

void solve() {
  int n, m, l, r;
  while (cin >> n >> m >> l >> r) {
    for (int i = 0; i <= n; i++) {
      cin >> a[i];
      if (i) a[i] += a[i - 1];
      a[i] %= mod;
    }
    for (int i = 0; i <= m; i++) {
      cin >> b[i];
    }

    int ans = 0;
    for (int i = 0; i <= m; i++) {
      int sr = r - i;
      sr = min(sr, n);
      if (sr < 0) continue;
      int sl = l - i;
      if (sl > n) continue;
      sl = max(0ll, sl);

      int tt;
      if (sl == 0)
        tt = 0;
      else
        tt = a[sl - 1];
      int ra = a[sr] - tt;
      ra = (ra % mod + mod) % mod;
      int res2 = b[i] * (ra) % mod;
      res2 = (res2 + mod) % mod;
      ans = (ans + res2) % mod;
    }
    cout << (ans % mod + mod) % mod << endl;
  }
}

signed main() {
  kd;
  int _;
  _ = 1;
  // cin>>_;
  while (_--) solve();
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 149ms
memory: 11400kb

input:

121 285 293 344
72406343 29062835 764055826 405957571 16850604 195010152 172508328 95932334 831517980 743997761 105129557 514312920 823346977 323074892 692747568 19841766 27687784 347985813 687459437 105444325 409463081 290623333 617535612 772316325 337644791 385678680 277673818 798282616 401321010 ...

output:

844655532
265155792
721082700
495929230
51368183
333395998
317686334
360990019
417166860
777286141
790612844
963001524
160679555
18876664
993526858
577807872
57755040
386940508
941107272
983715250
846414206
784228123
996873567
716573418
156108377
323145621
213071341
252732267
964022445
861123759
102...

result:

ok 1001 numbers