Submission #119065

#TimeUsernameProblemLanguageResultExecution timeMemory
119065oolimryTeams (IOI15_teams)C++14
Compilation error
0 ms0 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; typedef pair<int,int> ii; int n; ii arr[1000005]; void init(int N, int A[], int B[]) { n = N; for(int i = 0;i < n;i++){ arr[i] = {A[i],B[i]}; } sort(arr,arr+n); } int can(int M, int K[]) { int m = M; int s = 0; for(int i = 0;i < m;i++) s += K[i]; if(s > n) return 0; int tasks[s]; int cnt = 0; for(int i = 0;i < m;i++){ for(int j = 0;j < K[i];j++){ tasks[cnt] = K[i]; cnt++; } } sort(tasks,tasks+s); priority_queue<int, vector<int>, greater<int> > stuff; int index = 0; for(int i = 0;i < s;i++){ while(index < n && arr[index].first <= tasks[i]){ stuff.push(arr[index].second); index++; } while(true){ if(stuff.empty()){ return 0; } if(stuff.top() < tasks[i]){ stuff.pop(); } else{ stuff.pop(); break; } } //cout << stuff.size() << "\n"; } return 1; } int main() { freopen("i.txt","r",stdin); int N; cin >> N; int *A = (int*)malloc(sizeof(int)*(unsigned int)N); int *B = (int*)malloc(sizeof(int)*(unsigned int)N); for (int i = 0; i < N; ++i) { cin >> A[i] >> B[i]; } init(N, A, B); int Q; cin >> Q; for (int i = 0; i < Q; ++i) { int M; cin >> M; int *K = (int*)malloc(sizeof(int)*(unsigned int)M); for (int j = 0; j < M; ++j) { cin >> K[j]; } cout << can(M,K) << "\n"; } return 0; }

Compilation message (stderr)

teams.cpp: In function 'int main()':
teams.cpp:56:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("i.txt","r",stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~
/tmp/cc46Q7q3.o: In function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'
/tmp/cc75ZntA.o:teams.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status