제출 #568506

#제출 시각아이디문제언어결과실행 시간메모리
568506CSQ31Teams (IOI15_teams)C++17
0 / 100
102 ms23356 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; #define fi first #define se second int n; vector<pii>r; void init(int N, int A[], int B[]) { n = N; for(int i=0;i<n;i++)r.push_back({A[i],B[i]}); sort(r.begin(),r.end()); } int can(int m, int K[]) { int sum = 0; map<int,int>cnt; for(int i=0;i<m;i++){ sum+=K[i]; cnt[K[i]]++; if(sum>n)return 0; } vector<pii>a; for(auto x:cnt)a.push_back(x); int s = a.size(); vector<int>need(s); for(int i=0;i<s;i++)need[i] = a[i].fi * a[i].se; int ptr = -1; for(int i=0;i<s;i++){ int last = ptr; while(ptr+1<n && r[ptr+1].fi<=a[i].fi)ptr++; if(ptr == last)continue; vector<int>w; for(int j=last+1;j<=ptr;j++)w.push_back(a[j].se); sort(w.begin(),w.end()); for(int x:w){ for(int j=i;j<s;j++){ if(need[j] && a[j].se <= x){ need[j]--; break; } } } } for(int x:need){ if(x)return 0; } return 1; }

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

teams.cpp: In function 'int can(int, int*)':
teams.cpp:25:16: warning: conversion from 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   25 |  int s = a.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...