# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
577305 | 2022-06-14T13:33:59 Z | Mher777 | Fountain (eJOI20_fountain) | C++17 | 50 ms | 4468 KB |
#include <iostream> #include <vector> #include <array> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <string> using namespace std; typedef int itn; typedef long long ll; #define MAXL 1e18 + 9 #define MAX 1e9 + 9 #define ff first #define ss second #define pii pair<int,int> #define pll pair<ll,ll> #define mii map<int,int> #define mll map<ll,ll> #define vi vector<int> #define vll vector<ll> #define pub push_back #define puf push_front #define pob pop_back #define pof pop_front // 60 points const int N = 1e5 + 10; int go[N]; void solve() { int n, q; ll n1, n2; cin >> n >> q; vector<pair<int, pll>> v; for (int i = 0; i < n; i++) { cin >> n1 >> n2; v.pub({ i + 1, { n1, n2 } }); } v.pub({ 0, { MAXL, MAXL } }); ll sum; if (n <= 1000 && q <= 2000) { for (int i = 0; i < v.size(); i++) { for (int j = i + 1; j < v.size(); j++) { if (v[j].ss.ff > v[i].ss.ff) { go[v[i].ff] = v[j].ff; break; } } } while (q--) { cin >> n1 >> n2; sum = 0; while (sum < n2) { if (sum + v[n1 - 1].ss.ss >= n2) { cout << n1 << '\n'; break; } else { sum += v[n1 - 1].ss.ss; n1 = go[n1]; if (n1 == 0) { cout << n1 << '\n'; break; } } } } } else { } } int main() { solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 308 KB | Output is correct |
2 | Correct | 2 ms | 340 KB | Output is correct |
3 | Correct | 2 ms | 340 KB | Output is correct |
4 | Correct | 3 ms | 340 KB | Output is correct |
5 | Correct | 6 ms | 348 KB | Output is correct |
6 | Correct | 5 ms | 340 KB | Output is correct |
7 | Correct | 5 ms | 388 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 50 ms | 4468 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 308 KB | Output is correct |
2 | Correct | 2 ms | 340 KB | Output is correct |
3 | Correct | 2 ms | 340 KB | Output is correct |
4 | Correct | 3 ms | 340 KB | Output is correct |
5 | Correct | 6 ms | 348 KB | Output is correct |
6 | Correct | 5 ms | 340 KB | Output is correct |
7 | Correct | 5 ms | 388 KB | Output is correct |
8 | Incorrect | 50 ms | 4468 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |