Submission #536475

#TimeUsernameProblemLanguageResultExecution timeMemory
536475cig32Toll (BOI17_toll)C++17
7 / 100
15 ms1680 KiB
#include "bits/stdc++.h" using namespace std; const int MAXN = 2e5 + 10; const int MOD = 120717661; #define int long long #define ll __int128 mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count()); int rnd(int x, int y) { int u = uniform_int_distribution<int>(x, y)(rng); return u; } ll read() { // read int128 int x; cin >> x; return (ll)x; } long long bm(long long b, long long p) { if(p==0) return 1 % MOD; long long r = bm(b, p >> 1); if(p&1) return (((r*r) % MOD) * b) % MOD; return (r*r) % MOD; } long long inv(long long b) { return bm(b, MOD-2); } long long f[MAXN]; long long nCr(int n, int r) { long long ans = f[n]; ans *= inv(f[r]); ans %= MOD; ans *= inv(f[n-r]); ans %= MOD; return ans; } void precomp() { for(int i=0; i<MAXN; i++) f[i] = (i == 0 ? 1 % MOD : (f[i-1] * i) % MOD); } void solve(int tc) { int k, n, m, q; cin >> k >> n >> m >> q; if(k == 1) { int ps[n]; for(int i=0; i<n; i++) ps[i] = -1e13; for(int i=1; i<=m; i++) { int a, b, t; cin >> a >> b >> t; ps[a] = t; } for(int i=1; i<n; i++) ps[i] += ps[i-1]; for(int i=0; i<q; i++) { int a, b; cin >> a >> b; int p = ps[b - 1] - (a == 0 ? 0 : ps[a - 1]); if(p < 0) cout << "-1\n"; else cout << p << "\n"; } return; } } int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; for(int i=1; i<=t; i++) solve(i); }
#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...