Submission #472369

# Submission time Handle Problem Language Result Execution time Memory
472369 2021-09-13T12:28:08 Z elgamalsalman Toll (BOI17_toll) C++14
7 / 100
56 ms 5128 KB
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

ll k, n, m, o, pSum[50050];
vvii  adj;

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

  fill(pSum, pSum + 50050, -1e10);

  cin >> k >> n >> m >> o;
  adj.assign(n + 20, vii());
  for (ll i = 0; i < m; i++) {
    ll a, b, t;
    cin >> a >> b >> t;
    adj[a].push_back({b, t});
    pSum[b] = t;
  }
  
  for (int i = 1; i < 50050; i++) pSum[i] += pSum[i - 1];

  for (ll i = 0; i < o; i++) {
    ll a, b;
    cin >> a >> b;
    ll toll = pSum[b] - pSum[a];
    cout << (toll < 0 ? -1 : toll) << '\n';
  }
}
# Verdict Execution time Memory Grader output
1 Correct 27 ms 4164 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 28 ms 4292 KB Output is correct
9 Correct 23 ms 4288 KB Output is correct
10 Correct 4 ms 1996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 5128 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Incorrect 1 ms 716 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Incorrect 1 ms 716 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 4164 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 28 ms 4292 KB Output is correct
9 Correct 23 ms 4288 KB Output is correct
10 Correct 4 ms 1996 KB Output is correct
11 Incorrect 56 ms 5128 KB Output isn't correct
12 Halted 0 ms 0 KB -