Submission #466989

# Submission time Handle Problem Language Result Execution time Memory
466989 2021-08-21T07:28:30 Z mtxas Fountain (eJOI20_fountain) C++14
30 / 100
3 ms 332 KB
#include <bits/stdc++.h>

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define mfsadfp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mii map<int, int>
#define all(a) a.begin(), a.end()
#define _fre() freopen("input.txt", "r", stdin)
#define turbo() cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false)
#define sz(x) ((int)x.size())
#define _for(a, b, c) for(int (a) = (b); (a) < (c); (a)++)
#define _foreq(a, b, c) for(int (a) = (b); (a) <= (c); (a)++)
#define _forneq(a, b, c) for(int (a) = (b); (a) >= (c); (a)--)
#define _forn(a, b, c) for(int (a) = (b); (a) > (c); (a)--)
using namespace std;
/***********************************************************************************
                                 STRUCTS
************************************************************************************/

/***********************************************************************************
                                VARIABLES
************************************************************************************/
const int maxn = 2001;
int n, q;
int c[maxn], d[maxn], r[maxn], v[maxn];
/***********************************************************************************
                                FUNCTIONS
************************************************************************************/
int query(int R, int V){
    int lastId = 0;
    _foreq(j, R, n){
        while(d[j] <= d[lastId]){
            j++;
            if(j == n+1) return 0;
        } // d[j] > d[lastId]
        V-= c[j];
        if(V <= 0) return j;
        lastId = j;
    }
    return 0;
}

/***********************************************************************************
                                  MAIN
************************************************************************************/
int main(){
   // _fre();
    turbo();
    cin>>n>>q;
    _foreq(i, 1, n) cin>>d[i]>>c[i];
    _for(i, 0, q) cin>>r[i]>>v[i];
    _for(g, 0, q){
        cout<<query(r[g], v[g])<<'\n';
    }

}


Compilation message

fountain.cpp: In function 'int query(int, int)':
fountain.cpp:18:33: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   18 | #define _foreq(a, b, c) for(int (a) = (b); (a) <= (c); (a)++)
      |                                 ^
fountain.cpp:37:5: note: in expansion of macro '_foreq'
   37 |     _foreq(j, R, n){
      |     ^~~~~~
fountain.cpp: In function 'int main()':
fountain.cpp:18:33: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define _foreq(a, b, c) for(int (a) = (b); (a) <= (c); (a)++)
      |                                 ^
fountain.cpp:56:5: note: in expansion of macro '_foreq'
   56 |     _foreq(i, 1, n) cin>>d[i]>>c[i];
      |     ^~~~~~
fountain.cpp:17:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   17 | #define _for(a, b, c) for(int (a) = (b); (a) < (c); (a)++)
      |                               ^
fountain.cpp:57:5: note: in expansion of macro '_for'
   57 |     _for(i, 0, q) cin>>r[i]>>v[i];
      |     ^~~~
fountain.cpp:17:31: warning: unnecessary parentheses in declaration of 'g' [-Wparentheses]
   17 | #define _for(a, b, c) for(int (a) = (b); (a) < (c); (a)++)
      |                               ^
fountain.cpp:58:5: note: in expansion of macro '_for'
   58 |     _for(g, 0, q){
      |     ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 3 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 3 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Incorrect 1 ms 332 KB Output isn't correct
9 Halted 0 ms 0 KB -