Language: C++

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;

int T, N;
vector<int> t;
int tm[110];
int ed;

int memo[110];

int solve(int idx){
    if(memo[idx] != -1) return memo[idx];
    if(idx > ed) return 0;
    int res = INF;
    int startDay = idx;
    rep(i, idx, ed + 1){
        int nowDay = i;
        int wake = t[(nowDay - startDay) % T];
        // cout << idx << " " << i << ' ' << nowDay << " " << wake << endl;
        if(wake > tm[i]) break;
        int tmp = solve(i + 1);
        res = min(res, tmp);
    }
    // cout << idx << ' ' << res + 1 << endl;
    return memo[idx] = res + 1;
}

signed main(){
    while(cin >> T, T){
        t.clear();
        t.resize(T);
        rep(i, 0, T) cin >> t[i];
        cin >> N;
        memset(memo, -1, sizeof(memo));
        rep(i, 0, 110) tm[i] = INF;
        rep(i, 0, N){
            int a, b;
            cin >> a >> b;
            a--;
            tm[a] = min(tm[a], b);
        }
        rep(i, 0, 110){
            if(tm[i] == INF) continue;
            ed = i;
            // cout << " " << i << " " << tm[i] << endl;
        }
        int ans = solve(0);
        cout << ans - 1 << endl;
    }
}


Compiler output:
a.cc: In function 'long long int solve(long long int)':
a.cc:24:19: error: reference to 'tm' is ambiguous
   24 |         if(wake > tm[i]) break;
      |                   ^~
In file included from /usr/include/time.h:39,
                 from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/streambuf:43,
                 from /usr/include/c++/14/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:10:5: note:                 'long long int tm [110]'
   10 | int tm[110];
      |     ^~
a.cc: In function 'int main()':
a.cc:39:24: error: reference to 'tm' is ambiguous
   39 |         rep(i, 0, 110) tm[i] = INF;
      |                        ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:10:5: note:                 'long long int tm [110]'
   10 | int tm[110];
      |     ^~
a.cc:44:13: error: reference to 'tm' is ambiguous
   44 |             tm[a] = min(tm[a], b);
      |             ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:10:5: note:                 'long long int tm [110]'
   10 | int tm[110];
      |     ^~
a.cc:44:25: error: reference to 'tm' is ambiguous
   44 |             tm[a] = min(tm[a], b);
      |                         ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:10:5: note:                 'long long int tm [110]'
   10 | int tm[110];
      |     ^~
a.cc:47:16: error: reference to 'tm' is ambiguous
   47 |             if(tm[i] == INF) continue;
      |                ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:10:5: note:                 'long long int tm [110]'
   10 | int tm[110];
      |     ^~