답안 #152828

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
152828 2019-09-09T17:41:22 Z AldeaDanut Preokret (COCI18_preokret) C++14
50 / 50
3 ms 376 KB
#include <iostream>
#define x first
#define y second
using namespace std;

int a,b,A[3000],B[3000],cnt,i,j,n,s[3],lead;
pair <int,int> v[6000];

int main(){
    cin>>a;
    for(i=1;i<=a;i++)
        cin>>A[i];
    cin>>b;
    for(i=1;i<=b;i++)
        cin>>B[i];

    for(i=1,j=1;i<=a&&j<=b;){
        if(A[i]<B[j]){
            n++;
            v[n].x=A[i];
            v[n].y=0;
            i++;
        }else{
            n++;
            v[n].x=B[j];
            v[n].y=1;
            j++;
        }
    }

    for(;i<=a;i++)
        v[++n].x=A[i],v[n].y=0;
    for(;j<=b;j++)
        v[++n].x=B[j],v[n].y=1;

    for(i=1;i<=n;i++)
        if(v[i].x>1440)
            break;
    cout<<i-1<<"\n";

    lead=v[1].y;
    s[lead]++;
    for(i=2;i<=n;i++){
        s[v[i].y]++;
        if(s[lead]<s[1-lead]){
            cnt++;
            lead=1-lead;
            //cout<<v[i].x<<"-";
        }
    }

    cout<<cnt;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 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 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct