제출 #530317

#제출 시각아이디문제언어결과실행 시간메모리
530317ajpiano팀들 (IOI15_teams)C++17
0 / 100
1142 ms96856 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; #define f first #define s second typedef long long ll; typedef pair<int,int> pi; const int large = 5e5+5; vector<pi> bit[large]; //r, val void binit(){ for(int i = 1; i < large; i++) bit[i].push_back({-large,0}); } void add(int pos, int r){ for(; pos < large; pos += pos&-pos) bit[pos].push_back({r,bit[pos].back().s+1}); } int sum(int pos, int fr){ int ans = 0; for(; pos > 0; pos -= pos&-pos){ int l = 0, r = bit[pos].size(); while(r-l > 1){ int mid = (l+r)>>1; if(bit[pos][mid].f <= fr) l = mid; else r = mid; } ans += bit[pos][l].s; } return ans; } int sum(int l1, int l2, int r1, int r2){ //finds from (l1, l2], (r1, r2] return sum(l2,r2)-sum(l1,r2)-sum(l2,r1)+sum(l1, r1); } int n; void init(int _n, int _a[], int _b[]){ //input stuff n = _n; binit(); vector<pi> ranges(n); // r,l for(int i = 0; i < n; i++){ ranges[i] = {_b[i], _a[i]}; } sort(ranges.begin(), ranges.end()); //increasing r order for(auto &p: ranges){ add(p.s,p.f); } } int can(int m, int k[]){ //fix input vector<int> k2; for(int i = 0; i < m; i++) k2.push_back(k[i]); k2.push_back(0); k2.push_back(n+1); sort(k2.begin(), k2.end(), greater<int>()); int carry = 0; bool good = 1; for(int i = 1; i <= m; i++){ carry += k2[i]; int tleft = sum(0, k2[i], k2[i]-1, n+1); if(tleft < carry){ good = 0; break; } carry -= sum(k2[i+1], k2[i], k2[i]-1, n+1); carry = max(0, carry); } if(!good) return 0; return 1; }

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

teams.cpp: In function 'int sum(int, int)':
teams.cpp:30:37: warning: conversion from 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   30 |         int l = 0, r = bit[pos].size();
      |                        ~~~~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...