제출 #924286

#제출 시각아이디문제언어결과실행 시간메모리
924286Macker팀들 (IOI15_teams)C++14
0 / 100
347 ms147488 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 - 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() && i < 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]); } } 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();
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
teams.cpp: In function 'void init(int, int*, int*)':
teams.cpp:30:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   while(j < st[i * 2].size() && i < st[i * 2 + 1].size()){
      |         ~~^~~~~~~~~~~~~~~~~~
teams.cpp:30:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   while(j < st[i * 2].size() && i < st[i * 2 + 1].size()){
      |                                 ~~^~~~~~~~~~~~~~~~~~~~~~
teams.cpp:38:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   for (; j < st[i * 2].size(); j++) st[i].push_back(st[i * 2][j]);
      |          ~~^~~~~~~~~~~~~~~~~~
teams.cpp:39:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   for (; k < st[i * 2 + 1].size(); k++) st[i].push_back(st[i * 2 + 1][k]);
      |          ~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...