fork download
  1. // Problem: A. Founder DNA Match – The Human Capital Engine
  2. // Contest: Codeforces - ECPC 2025 (Mirror)
  3. // URL: https://c...content-available-to-author-only...s.com/group/Rilx5irOux/contest/628229/problem/A
  4. // Memory Limit: 256 MB
  5. // Time Limit: 3000 ms
  6. //
  7. // Powered by CP Editor (https://c...content-available-to-author-only...r.org)
  8.  
  9. #include <bits/stdc++.h>
  10. using namespace std;
  11.  
  12. bool multicases_=false;
  13.  
  14. #include <ext/pb_ds/assoc_container.hpp>
  15. #include <ext/pb_ds/tree_policy.hpp>
  16. using namespace __gnu_pbds;
  17. // template<class T>using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
  18. template<typename T>using ordered_multiset = tree<pair<T, int>, null_type, less<pair<T, int>>, rb_tree_tag, tree_order_statistics_node_update>;
  19. template<typename T>using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
  20.  
  21. using ll = long long;
  22. #define int long long//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<??
  23. typedef unsigned long long u64;//this or the one below
  24. #define ull unsigned long long
  25.  
  26. void pre_compute(){
  27.  
  28. }
  29.  
  30. void solve(int tc){
  31. // //dbg:
  32. // cerr<<"at the test case no."<<tc<<" : \n";
  33.  
  34. int n; cin>>n;
  35. int arr[2]={0,0};
  36.  
  37. /////////// h,q;//happiness change(increase/decrease) ,, quantity
  38. vector<pair<int,int>>v(n);
  39. for(auto&[h,q]:v){
  40. cin>>h>>q;
  41. h=(h==1?1:-1);
  42.  
  43. }
  44.  
  45. int turn=1;
  46. for(auto&[h,q]:v){
  47.  
  48. if(turn==1){
  49. arr[0]+=h*q;
  50. if(arr[0]<0)return void(cout<<"AHMED");
  51. } else {
  52. arr[1]+=h*q;
  53. if(arr[1]<0)return void(cout<<"AMIRA");
  54. }
  55.  
  56.  
  57. turn*=-1;
  58.  
  59. //dbg
  60. // cerr<<arr[0]<<' '<<arr[1]<<'\n';
  61.  
  62. }
  63. cout<<"DRAW";
  64. }
  65.  
  66. signed main(){
  67. ios::sync_with_stdio(0);cin.tie(0);
  68.  
  69. pre_compute();
  70.  
  71. int tc=1;
  72. if(multicases_)cin>>tc;
  73. int total_tcs=tc;
  74. while(tc--){
  75. solve(total_tcs-tc);
  76. }
  77. return 0;
  78. }
Success #stdin #stdout 0.01s 5312KB
stdin
4
1 3
1 2
2 7
1 1
stdout
AHMED