제출 #1121062

#제출 시각아이디문제언어결과실행 시간메모리
1121062SalihSahin팀들 (IOI15_teams)C++14
34 / 100
4072 ms12496 KiB
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
#include "teams.h"

vector<pair<int, int> > st;

bool comp(pair<int, int> p1, pair<int, int> p2){
    if(p1.second == p2.second) return (p1.first < p2.first);
    else return (p1.second < p2.second);
}

void init(int N, int A[], int B[]){
    for(int i = 0; i < N; i++){
        st.pb({A[i], B[i]});
    }
    sort(st.begin(), st.end(), comp);
}

int can(int M, int K[]) {
    sort(K, K + M);
    vector<int> cnt(M);
    for(int i = 0; i < st.size(); i++){
        auto starti = lower_bound(K, K + M, st[i].first) - K;
        if(starti >= M) continue;
        auto endi = upper_bound(K, K + M, st[i].second) - K;

        for(int j = starti; j < endi; j++){
            if(cnt[j] < K[j]){
                cnt[j]++;
                break;
            }
        }
    }

    bool ok = 1;
    for(int i = 0; i < M; i++){
        if(cnt[i] != K[i]) ok = 0;
    }

    return ok;
}

컴파일 시 표준 에러 (stderr) 메시지

teams.cpp: In function 'int can(int, int*)':
teams.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i = 0; i < st.size(); i++){
      |                    ~~^~~~~~~~~~~
teams.cpp:28:21: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   28 |         for(int j = starti; j < endi; j++){
      |                     ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...