답안 #560977

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
560977 2022-05-12T06:32:35 Z AGE Preokret (COCI18_preokret) C++14
12.4 / 50
1 ms 212 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define int long long
using namespace std;
const int N=1e5+5,M=2e3+10,mod=100000000000031;
vector<int>v;

long long  summ(long long  x,long long  y){
    return ((x%mod)+(y%mod))%mod;
}

long long  mult(long long  x,long long  y){
    return ((x%mod)*(y%mod))%mod;
}

main()
{
    int n,m;
    cin>>n;

    int cnt1=0,cnt2=0,cnt=0,ans=0;
    vector<int>v,vv;

    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.pb(x);
    }

    cin>>m;

    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        vv.pb(x);
    }

    reverse(vv.begin(),vv.end());
    reverse(v.begin(),v.end());
    int ok=0;
    int timee;

    while(v.size()!=0&&vv.size()!=0){

        if(*v.rbegin()<*vv.rbegin())
            timee=*v.rbegin(),v.pop_back(),cnt1++;

        else
            timee=*vv.rbegin(),vv.pop_back(),cnt2++;

        if(cnt1>cnt2&&ok==2)
            ok=1,ans++;

        else if(cnt1<cnt2&&ok==1)
            ok=2,ans++;

        if(ok==0)
            if(cnt1>cnt2)
                ok=1;
            else
                ok=2;
        if(timee<=1400)
            cnt++;

    }

    while(v.size()!=0){

        timee=*v.rbegin();

        v.pop_back();

        cnt1++;

        if(cnt1>cnt2&&ok==2)
            ok=1,ans++;

        if(timee<=1400)
            cnt++;

    }

    while(vv.size()!=0){

        timee=*vv.rbegin();

        vv.pop_back();

        cnt2++;

        if(cnt2>cnt1&&ok==1)
            ok=2,ans++;

        if(timee<=1400)
            cnt++;

    }

    cout<<cnt<<endl;

    cout<<ans<<endl;
    return 0;
}

/*
5 4
...#
..#.
#..#
....
....
*/

Compilation message

preokret.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   18 | main()
      | ^~~~
preokret.cpp: In function 'int main()':
preokret.cpp:59:11: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   59 |         if(ok==0)
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Partially correct 0 ms 212 KB Output is partially correct
4 Partially correct 0 ms 212 KB Output is partially correct
5 Partially correct 1 ms 212 KB Output is partially correct
6 Partially correct 1 ms 212 KB Output is partially correct
7 Partially correct 1 ms 212 KB Output is partially correct
8 Partially correct 1 ms 212 KB Output is partially correct
9 Partially correct 1 ms 212 KB Output is partially correct
10 Partially correct 0 ms 212 KB Output is partially correct