Submission #1111455

#TimeUsernameProblemLanguageResultExecution timeMemory
1111455gelastropodTrains (BOI24_trains)C++14
0 / 100
29 ms1896 KiB
#include<bits/stdc++.h> using namespace std; #define int long long vector<int> tree; void upd(int n, int x) { while (n < tree.size()) { tree[n] += x; tree[n] %= 1000000007; n += n & (-n); } } int qry(int a) { if (a == 0) return 0; if (a >= tree.size()) return qry(tree.size() - 1); int ans = 0; while (a > 0) { ans += tree[a]; ans %= 1000000007; a -= a & (-a); } return ans; } signed main() { int N, a, b; cin >> N; tree = vector<int>(N + 1, 0); vector<pair<int, int>> vals; for (int i = 0; i < N; i++) { cin >> a >> b; vals.push_back({a, b}); } for (int i = N - 1; i >= 0; i--) { if (i + 1 >= N) upd(i + 1, 1); else upd(i + 1, (qry(i + 1 + vals[i].second) - qry(i)) % 1000000007); } cout << qry(1) << '\n'; }

Compilation message (stderr)

Main.cpp: In function 'void upd(long long int, long long int)':
Main.cpp:9:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     while (n < tree.size())
      |            ~~^~~~~~~~~~~~~
Main.cpp: In function 'long long int qry(long long int)':
Main.cpp:21:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     if (a >= tree.size())
      |         ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...