Submission #885400

#TimeUsernameProblemLanguageResultExecution timeMemory
885400abcvuitunggioTeams (IOI15_teams)C++17
0 / 100
1580 ms45732 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; int n,cnt[500001],a[500002],dp[1010][1010]; vector <int> v[500001]; void init(int N, int A[], int B[]){ n=N; for (int i=0;i<n;i++){ a[A[i]]++; a[B[i]+1]--; v[A[i]].push_back(B[i]); } for (int i=1;i<=n;i++){ a[i]+=a[i-1]; sort(v[i].begin(),v[i].end()); } } int can(int M, int K[]){ int sum=0; for (int i=0;i<M;i++){ sum+=K[i]; if (sum>n) return 0; } vector <int> ve; for (int i=0;i<M;i++){ cnt[K[i]]++; if (cnt[K[i]]==1) ve.push_back(K[i]); } ve.push_back(0); sort(ve.begin(),ve.end()); int mx=0; for (int j=ve.size()-1;j>=0;j--){ int cur=-a[ve[j]]; for (int i=0;i<j;i++){ cur+=v[i].size()-(lower_bound(v[i].begin(),v[i].end(),ve[j])-v[i].begin()); dp[i][j]=max(dp[i][j+1],dp[j][j+1]+ve[j]*cnt[ve[j]]+cur); if (!i) mx=max(mx,dp[i][j]); } } for (int i=ve.size()-1;i>=0;i--) for (int j=ve.size()-1;j>i;j--) dp[i][j]=0; for (int i=0;i<M;i++) cnt[K[i]]=0; return (!mx); }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:34:25: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   34 |     for (int j=ve.size()-1;j>=0;j--){
      |                ~~~~~~~~~^~
teams.cpp:37:86: warning: conversion from 'long unsigned int' to 'int' may change value [-Wconversion]
   37 |             cur+=v[i].size()-(lower_bound(v[i].begin(),v[i].end(),ve[j])-v[i].begin());
      |                                                                                      ^
teams.cpp:43:25: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   43 |     for (int i=ve.size()-1;i>=0;i--)
      |                ~~~~~~~~~^~
teams.cpp:44:29: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   44 |         for (int j=ve.size()-1;j>i;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...