답안 #198154

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
198154 2020-01-24T22:37:08 Z mkisic Zoltan (COCI16_zoltan) C++14
0 / 140
346 ms 11620 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair
#define pb push_back

const int MAXN = 200100;
const int offset = (1 << 18);
const int MOD = 1e9 + 7;

int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}

struct tournament {
  pii p[offset * 2];

  tournament() {
    REP(i, offset * 2) p[i] = {0, 0};
  }

  pii merge(pii a, pii b) {
    if (a.fi > b.fi) return a;
    if (b.fi > a.fi) return b;
    return {a.fi, add(a.sec, b.sec)};
  }

  void update(int a, pii b) {
    a += offset;
    p[a] = merge(p[a], b);
    a /= 2;
    while (a) {
      p[a] = merge(p[a * 2], p[a * 2 + 1]);
      a /= 2;
    }
  }

  pii get(int cvor, int l, int r, int a, int b) {
    if (l > b || r < a || l > r) return {0, 0};
    if (l >= a && r <= b) return p[cvor];

    int mid = (l + r) / 2;
    pii x = get(cvor * 2, l, mid, a, b);
    pii y = get(cvor * 2 + 1, mid + 1, r, a, b);
    return merge(x, y);
  }
};

tournament T;

int n;

vector <int> saz;
vector <pii> pt;

int main() {
  scanf("%d",&n);
  REP(i, n) {
    int x;
    scanf("%d",&x);
    saz.pb(x);
    pt.pb({-(i + 1), x});
    pt.pb({i + 1, x});
  }

  sort(all(saz));
  saz.erase(unique(all(saz)), saz.end());

  sort(all(pt));
  pii ans;

  REP(i, (int)pt.size()) {
    pt[i].sec = lower_bound(all(saz), pt[i].sec) - saz.begin();
    pii t = T.get(1, 0, offset - 1, 0, pt[i].sec - 1);
    if (t.fi == 0) t.sec = 1;
    t.fi++;
    ans = T.merge(ans, t);
    T.update(pt[i].sec, t);
  }

  printf("%d %d\n",ans.fi,ans.sec);
  return 0;
}

Compilation message

zoltan.cpp: In function 'int main()':
zoltan.cpp:73:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
   ~~~~~^~~~~~~~~
zoltan.cpp:76:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&x);
     ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 4472 KB Output isn't correct
2 Incorrect 5 ms 4472 KB Output isn't correct
3 Incorrect 6 ms 4344 KB Output isn't correct
4 Incorrect 6 ms 4472 KB Output isn't correct
5 Incorrect 6 ms 4472 KB Output isn't correct
6 Incorrect 7 ms 4344 KB Output isn't correct
7 Incorrect 7 ms 4472 KB Output isn't correct
8 Incorrect 7 ms 4472 KB Output isn't correct
9 Incorrect 7 ms 4472 KB Output isn't correct
10 Incorrect 7 ms 4476 KB Output isn't correct
11 Incorrect 201 ms 11236 KB Output isn't correct
12 Incorrect 175 ms 11108 KB Output isn't correct
13 Incorrect 163 ms 8420 KB Output isn't correct
14 Incorrect 224 ms 11492 KB Output isn't correct
15 Incorrect 295 ms 11564 KB Output isn't correct
16 Incorrect 346 ms 11620 KB Output isn't correct
17 Incorrect 234 ms 11108 KB Output isn't correct
18 Incorrect 287 ms 11108 KB Output isn't correct
19 Incorrect 235 ms 11108 KB Output isn't correct
20 Incorrect 254 ms 11108 KB Output isn't correct