Submission #466984

#TimeUsernameProblemLanguageResultExecution timeMemory
466984mtxasFountain (eJOI20_fountain)C++14
0 / 100
1 ms332 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...