Submission #714760

#TimeUsernameProblemLanguageResultExecution timeMemory
714760KINGToll (BOI17_toll)C++14
0 / 100
48 ms7244 KiB
#include<bits/stdc++.h>
#define NOT_STONKS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;
const int maxn = 2e5 + 10; //4e6 + 10; //3e5 + 10;
const int mod = 1e9 + 7; //998244353;
typedef long long ll;

int k, n, m, o, arr[maxn];
ll psum[maxn];
vector< pair<int, int> > G[maxn];

int main() {
    NOT_STONKS;

    cin >> k >> n >> m >> o;
    for (int i = 0; i < m; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        G[u].push_back({ v, w });
        arr[v] = w;
    }
    for (int i = 1; i <= n; i++) psum[i] = psum[i - 1] + arr[i];
    while (o--) {
        int a, b;
        cin >> a >> b;
        cout << psum[b] - psum[a] << endl;
    }
    return 0;
}

#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...