답안 #199699

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
199699 2020-02-02T22:04:17 Z triplem5ds Preokret (COCI18_preokret) C++14
50 / 50
6 ms 376 KB
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 3e5 + 5, LG = 19, MOD = 1e9 + 7;
const int SQ =225;
const long double EPS = 1e-7;
int A,B,x,ans,ans2;
int cnt[2880];
int main(){

  cin >> A;

  f(i,0,A){
    cin >> x;
    cnt[x]++;
    if(x<=1440)ans++;
  }

  cin >> B;

  f(i,0,B){
    cin >> x;
    cnt[x]--;
    if(x<=1440)ans++;
  }

  vector<int> vp;
  int cur = 0;
  f(i,1,2880){

    if(cnt[i]){
      cur += cnt[i];
      if(vp.size() >= 2 && ((cur > 0 && vp[vp.size()-2] < 0)||(cur < 0 && vp[vp.size()-2] > 0))){
        ans2++;
      }
      vp.push_back(cur);
    }
  }

  cout << ans << "\n";
  cout << ans2 << endl;


	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct