Submission #548462

# Submission time Handle Problem Language Result Execution time Memory
548462 2022-04-13T13:21:15 Z shmad Fountain (eJOI20_fountain) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#pragma optimize ("g",on)
#pragma GCC optimize ("inline")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("03")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
#pragma comment(linker, "/stack:200000000")

#define pb push_back
#define pob pop_back
#define ll long long
#define ld long double
#define int ll // HERE CAN BE WA/RE/MLE/TLE
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define sz(s) s.size()
#define skip continue
#define y0 ijl
#define y1 hjk
#define equal bayan
#define friend trs
#define delete bae
#define div aber
#define exp earb
#define new heiu
#define t1 sgher
#define t0 sorei

using namespace std;

const int N = 1e6 + 7;
const int K = 1e7 + 7;
const int WN = 1e7 + 7;
const int inf = 1e9 + 7;
const int INF = 1e18 + 7;
const int MOD = 1e9 + 7;
const double eps = 1e-6;



int p[N];
void solve() {
    int n, q;
    cin >> n >> q;
    vector <pair <int, int>> v(n + 1);
    for (int i = 1;i <= n;i++) {
        cin >> v[i].x >> v[i].y;
        p[i] = p[i - 1] + v[i].y;
    }
    //for (int i = 1;i <= n;i++)cout << p[i] << ' ';
    if (n <= 1000 && q <= 2000) {
        while (q--) {
            int pos, sum;
            cin >> pos >> sum;
            int last = v[pos].x;
            sum -= v[pos].y;
            if (sum <= 0) {
                cout << pos << '\n';
                skip;
            }
            for (int i = pos + 1;i <= n;i++) {
                if (v[i].x > last) {
                    sum -= v[i].y;
                    if (sum <= 0) {
                        cout << i << '\n';
                        break;
                    }
                    last = v[i].x;
                }
            }
            if (sum > 0) {
                cout << 0 << '\n';
                skip;
            }
        }
        return;
    }else {
        while (q--) {
            int pos, sum;
            cin >> pos >> sum;
            int l = 1, r = n;
while (l + 1 < r) {
                int mid = (l + r) / 2;
                if (p[mid] - p[pos - 1] < sum)l = mid;
                else r = mid;
            }
            cout << l << '\n';
        }
    }
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("Hardproblem.in", "r", stdin);
    //freopen("Hardproblem.out", "w", stdout);
    int t;
    t = 1;
    //cin >> t;
    for (int i = 1;i <= t;i++) {
        //cout << i << ':';
        solve();
    }
  return 0;
}

Compilation message

fountain.cpp:2: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    2 | #pragma optimize ("g",on)
      | 
fountain.cpp:8: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    8 | #pragma comment(linker, "/stack:200000000")
      | 
fountain.cpp:83:2: error: extended character   is not valid in an identifier
   83 |             int l = 1, r = n;
      |  ^
fountain.cpp:83:5: error: extended character   is not valid in an identifier
   83 |             int l = 1, r = n;
      |    ^
fountain.cpp:83:8: error: extended character   is not valid in an identifier
   83 |             int l = 1, r = n;
      |      ^
fountain.cpp:83:11: error: extended character   is not valid in an identifier
   83 |             int l = 1, r = n;
      |        ^
fountain.cpp:83:14: error: extended character   is not valid in an identifier
   83 |             int l = 1, r = n;
      |          ^
fountain.cpp:83:17: error: extended character   is not valid in an identifier
   83 |             int l = 1, r = n;
      |            ^
fountain.cpp: In function 'void solve()':
fountain.cpp:83:2: error: '\U000000a0' was not declared in this scope
   83 |             int l = 1, r = n;
      |  ^
fountain.cpp:84:8: error: 'l' was not declared in this scope
   84 | while (l + 1 < r) {
      |        ^
fountain.cpp:84:16: error: 'r' was not declared in this scope
   84 | while (l + 1 < r) {
      |                ^
fountain.cpp:89:21: error: 'l' was not declared in this scope
   89 |             cout << l << '\n';
      |                     ^