제출 #568878

#제출 시각아이디문제언어결과실행 시간메모리
568878nonsensenonsense1Fish 2 (JOI22_fish2)C++17
13 / 100
4069 ms4360 KiB
#include <cstdio> #include <utility> #include <algorithm> const int N = 100005; int n, q, a[N], le[N], ri[N], cnt[N]; std::pair<int, int> b[N]; bool u[N]; long long sum[N]; int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) scanf("%d", a + i); scanf("%d", &q); while (q--) { int t; scanf("%d", &t); if (t == 1) { int x, y; scanf("%d%d", &x, &y); a[x - 1] = y; } else { int l, r; scanf("%d%d", &l, &r); --l; int len = r - l; for (int i = 0; i < len; ++i) { b[i] = std::make_pair(a[l + i], i); sum[i + 1] = sum[i] + a[l + i]; le[i] = ri[i] = i; cnt[i] = 0; u[i] = 0; } std::sort(b, b + len); for (int i = 0; i < len; ++i) { int id = b[i].second; u[id] = 1; int ll = id && u[id - 1] ? le[id - 1] : id, rr = id + 1 < len && u[id + 1] ? ri[id + 1] : id, curcnt = 1; if (sum[rr + 1] - sum[id + 1] >= sum[id + 1] - sum[id]) curcnt += cnt[id + 1]; if (sum[id] - sum[ll] >= sum[id + 1] - sum[id]) curcnt += cnt[id - 1]; ri[ll] = rr; le[rr] = ll; cnt[ll] = cnt[rr] = curcnt; } printf("%d\n", cnt[0]); } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

fish2.cpp: In function 'int main()':
fish2.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
fish2.cpp:13:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  for (int i = 0; i < n; ++i) scanf("%d", a + i);
      |                              ~~~~~^~~~~~~~~~~~~
fish2.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%d", &q);
      |  ~~~~~^~~~~~~~~~
fish2.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d", &t);
      |   ~~~~~^~~~~~~~~~
fish2.cpp:20:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |    scanf("%d%d", &x, &y);
      |    ~~~~~^~~~~~~~~~~~~~~~
fish2.cpp:24:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |    scanf("%d%d", &l, &r);
      |    ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...