Submission #641943

# Submission time Handle Problem Language Result Execution time Memory
641943 2022-09-17T23:48:30 Z Ahmed_Solyman Preokret (COCI18_preokret) C++14
50 / 50
1 ms 456 KB
#include <bits/stdc++.h>
#include <ext/rope>
 
using namespace std;
using namespace __gnu_cxx;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("-O1")
//-------------------------------------------------------------//
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sum_to(n) (n*(n+1))/2
#define pb push_back
#define pf push_front
#define sz size()
const ll mod=1e9+7;
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
//-------------------------------------------------------------//
ll lcm(ll a,ll b)
{
    return (max(a,b)/__gcd(a,b))*min(a,b);
}
void person_bool(bool x)
{
    cout<<(x?"YES":"NO")<<endl;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    fast
    int a;cin>>a;
    bool x[2900]={};
    for(int i=0;i<a;i++){
    	int p;cin>>p;
    	x[p]=1;
    }
    int b;cin>>b;
    bool y[2900]={};
    for(int i=0;i<b;i++){
    	int p;cin>>p;
    	y[p]=1;
    }
    int l=0,r=0;
    int d=0,f=0;
    map<int,pair<int,int>>mp;
    mp[-1]={0,0};
    int u=0;
    for(int i=1;i<=2880;i++){
    	if(x[i]){
    		l+=(i<=1440);
    		d++;
    		if(d>f && mp[u-2].first<mp[u-2].second){
    			r++;
    		}
    		mp[u++]={d,f};
    	}
    	else if(y[i]){
    		l+=(i<=1440);
    		f++;
    		if(f>d && mp[u-2].first>mp[u-2].second){
    			r++;
    		}
    		mp[u++]={d,f};
    	}
    }
    cout<<l<<endl;
    cout<<r<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 456 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 0 ms 212 KB Output is correct