Submission #167587

#TimeUsernameProblemLanguageResultExecution timeMemory
167587abilWeighting stones (IZhO11_stones)C++14
100 / 100
65 ms4572 KiB
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define mk make_pair #define all(s) s.begin(),s.end() //#define int long long using namespace std; const int N = (1e6 + 12); const int mod = (1e9 + 7); const int INF = (0x3f3f3f3f); int mx[N], mn[N], sum[N]; void push(int v,int l,int r){ if(l != r){ sum[v + v] += sum[v]; sum[v + v + 1] += sum[v]; } mx[v] += sum[v]; mn[v] += sum[v]; sum[v] = 0; } void upd(int v, int tl, int tr,int l,int r, int val){ push(v, tl, tr); if(tl > r || tr < l){ return; } if(l <= tl && tr <= r){ sum[v] += val; push(v, tl, tr); return; } int mid = (tl + tr) >> 1; upd(v + v, tl, mid, l, r, val); upd(v + v + 1, mid + 1, tr, l, r, val); mx[v] = max(mx[v + v], mx[v + v + 1]); mn[v] = min(mn[v + v], mn[v + v + 1]); } main() { int n, ves, side, ans; scanf("%d", &n); int test = n; while(test--){ scanf("%d%d", &ves, &side); if(side == 1){ upd(1, 1, n, 1, ves, 1); } else{ upd(1, 1, n, 1, ves, -1); } if(mx[1] >= 0 && mn[1] >= 0){ puts(">"); } else if(mx[1] <= 0 && mn[1] <= 0){ puts("<"); } else{ puts("?"); } } }

Compilation message (stderr)

stones.cpp:45:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
stones.cpp: In function 'int main()':
stones.cpp:47:20: warning: unused variable 'ans' [-Wunused-variable]
  int n, ves, side, ans;
                    ^~~
stones.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
stones.cpp:51:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &ves, &side);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...