Submission #505115

# Submission time Handle Problem Language Result Execution time Memory
505115 2022-01-10T15:12:41 Z theshadow_04 Preokret (COCI18_preokret) C++14
50 / 50
1 ms 332 KB
// annotshy

#include <bits/stdc++.h>

#define Task "CF"
#define F first
#define S second
#define sz(x) (int) x.size()
#define MOD 1000000007
#define pb push_back

using namespace std;

const int maxn = 1005;

int nA, nB;
vector<pair<int, int> > event;

void Solve(int Test) {
  cin >> nA;
  for(int i = 1; i <= nA; ++ i) {
    int t; cin >> t;
    event.pb({t, 0});
  }
  cin >> nB;
  for(int i = 1; i <= nB; ++ i) {
    int t; cin >> t;
    event.pb({t, 1});
  }
  sort(event.begin(), event.end());
  int res_score = 0, res_turn = 0;
  int last = -1, cnt0 = 0, cnt1 = 0;
  for(auto x : event) {
    if(x.F <= 1440) ++ res_score;
    if(x.S == 0) cnt0 ++;
    else cnt1 ++;
    if(cnt0 > cnt1) {
      if(last == -1) last = 0;
      else if(last == 1) ++ res_turn, last = 0;
    }
    if(cnt1 > cnt0) {
      if(last == -1) last = 1;
      else if(last == 0) ++ res_turn, last = 1;
    }
  }
  cout << res_score << "\n" << res_turn << "\n";
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  if(fopen(Task".inp", "r")) {
    freopen(Task".inp", "r", stdin);
    freopen(Task".out", "w", stdout);
  }
  int test = 1;
//  cin >> test;
  for(int i = 1; i <= test; ++ i) {
    Solve(i);
  }
}

/*no pain no gain*/

Compilation message

preokret.cpp: In function 'int main()':
preokret.cpp:53:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |     freopen(Task".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
preokret.cpp:54:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |     freopen(Task".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 204 KB Output is correct