답안 #341935

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341935 2020-12-31T14:37:07 Z Hazem Preokret (COCI18_preokret) C++14
50 / 50
1 ms 364 KB
/*
ID: tmhazem1
LANG: C++14
TASK: pprime
*/

#include <bits/stdc++.h>
using namespace std;

#define S second
#define F first
#define LL long long

const int N = 2e5 + 10;


LL LINF = 100000000000000000;
LL INF = 1000000000;
int MOD = 1e9+7;

vector<pair<int,int>>vec;
int cnt[N][2];

int main()
{
    // freopen("out.txt","w",stdout);
    int n,m;
    scanf("%d",&n);

    for(int i=1;i<=n;i++){
        int x;scanf("%d",&x);
        vec.push_back({x,0});
    }
    scanf("%d",&m);
    for(int i=1;i<=m;i++){
        int x;scanf("%d",&x);
        vec.push_back({x,1});
    }

    vec.push_back({0,3});
    sort(vec.begin(),vec.end());

    int cnt1 = 0,cnt2 = 0;
    for(int i=1;i<vec.size();i++){

        if(vec[i].F<=1440)cnt1++;
        
        for(int j=0;j<2;j++)
            cnt[i][j] = cnt[i-1][j]+(vec[i].S==j);

        if(i<=2||cnt[i][0]==cnt[i][1])continue;

        int idx = cnt[i][0]>cnt[i][1]?0:1;
        cnt2 += cnt[i-2][idx]<cnt[i-2][!idx]; 
    }
    printf("%d\n%d",cnt1,cnt2);
}       

Compilation message

preokret.cpp: In function 'int main()':
preokret.cpp:44:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int i=1;i<vec.size();i++){
      |                 ~^~~~~~~~~~~
preokret.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
preokret.cpp:31:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   31 |         int x;scanf("%d",&x);
      |               ~~~~~^~~~~~~~~
preokret.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   34 |     scanf("%d",&m);
      |     ~~~~~^~~~~~~~~
preokret.cpp:36:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   36 |         int x;scanf("%d",&x);
      |               ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct