제출 #924296

#제출 시각아이디문제언어결과실행 시간메모리
924296Macker팀들 (IOI15_teams)C++17
0 / 100
703 ms91404 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(v) v.begin(), v.end() vector<vector<int>> st; int len = 1; int qry(int l, int r, int val, int i = 1, int s = 0, int e = len){ if(l >= e || s >= r) return 0; if(l <= s && e <= r){ return upper_bound(all(st[i]), val) - st[i].begin(); } return qry(l, r, val, i * 2, s, (s + e) / 2) + qry(l, r, val, i * 2 + 1, (s + e) / 2, e); } void init(int N, int A[], int B[]) { while(len < N + 1) len *= 2; st.resize(2 * len); for (int i = 0; i < N; i++) { st[len + B[i]].push_back(A[i]); } for (int i = len; i < 2 * len; i++) sort(all(st[i])); /* for (int i = len - 1; i > 0; i--) { int j = 0, k = 0; st[i].reserve(st[i * 2].size() + st[i * 2 + 1].size()); while(j < st[i * 2].size() && k < st[i * 2 + 1].size()){ if(st[i * 2][j] < st[i * 2 + 1][k]){ st[i].push_back(st[i * 2][j++]); } else{ st[i].push_back(st[i * 2 + 1][k++]); } } for (; j < st[i * 2].size(); j++) st[i].push_back(st[i * 2][j]); for (; k < st[i * 2 + 1].size(); k++) st[i].push_back(st[i * 2 + 1][k]); } */ for (int i = len - 1; i >= 0; i--) { vector<int> a = st[i * 2]; a.insert(a.end(), all(st[i * 2 + 1])); sort(all(a)); st[i] = a; } } int can(int M, int K[]) { sort(K, K + M, greater<int>()); int rem = 0; for (int i = 0; i < M; i++) { int my, a, b; a = qry(K[i], len + 1, K[i]); if(i != M - 1) b = qry(K[i], len + 1, K[i + 1]); else b = 0; my = a - b; rem += K[i]; if(rem > a) return 0; rem -= my; } return 1; }

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

teams.cpp: In function 'int qry(int, int, int, int, int, int)':
teams.cpp:14:39: warning: conversion from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'} to 'int' may change value [-Wconversion]
   14 |   return upper_bound(all(st[i]), val) - st[i].begin();
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...