Submission #466984

# Submission time Handle Problem Language Result Execution time Memory
466984 2021-08-21T07:19:27 Z mtxas Fountain (eJOI20_fountain) C++14
0 / 100
1 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 = 1001;
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++; // 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:53:5: note: in expansion of macro '_foreq'
   53 |     _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:54:5: note: in expansion of macro '_for'
   54 |     _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:55:5: note: in expansion of macro '_for'
   55 |     _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 Incorrect 1 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 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 Incorrect 1 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -