Submission #120435

# Submission time Handle Problem Language Result Execution time Memory
120435 2019-06-24T13:11:25 Z cvele Preokret (COCI18_preokret) C++14
50 / 50
3 ms 384 KB
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  vector < pair <int, int> > vec;
  int n, m;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    vec.push_back({x, 0});
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    vec.push_back({x, 1});
  }
  sort(vec.begin(), vec.end());
  int ans = 0, res = 0;
  int lst = -1;
  int a = 0, b = 0;
  for (int i = 0; i < vec.size(); i++) {
    ans += vec[i].first <= 1440;
    a += (vec[i].second == 0);
    b += (vec[i].second == 1);
    if (lst == -1) {
      if (a > b) {
        lst = 0;
      } else {
        lst = 1;
      }
    }
    if (lst == 0) {
      if (b > a) {
        lst = 1;
        res++;
      }
    } else if (lst == 1) {
      if (a > b) {
        lst = 0;
        res++;
      }
    }
  }
  cout << ans << endl << res << endl;
  return 0;
}

Compilation message

preokret.cpp: In function 'int main()':
preokret.cpp:40:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < vec.size(); i++) {
                   ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct