Advertisement
Guest User

TOI14_day1_task1

a guest
Jun 20th, 2018
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. // TOI14_day1_task1
  2. #include <bits/extc++.h>
  3. #include <iostream>
  4. #define input() (*std::istream_iterator<lli>(cin))
  5. #define rep(i,k,n) for(auto i=k; i!=n; ++i)
  6. #define loop(i,n)  for(auto i=n; i--;)
  7. #define all(x) x.begin(), x.end()
  8. using namespace std;
  9. typedef long long lli;
  10.  
  11. int main(){
  12.     cin.sync_with_stdio(0);
  13.     int n = input();
  14.     std::vector<lli> inp(n + 1);
  15.     rep(i,0,n){
  16.         inp[i+1] = inp[i] + input();
  17.     }
  18.     std::sort(all(inp));
  19.     loop(_,input()){
  20.         auto it = std::upper_bound(all(inp), input());
  21.         printf(it == inp.begin() ? "sad\n" : "%lldn", *--it);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement