Task: | Järjestys |
Sender: | Alex |
Submission time: | 2016-10-13 15:53:44 +0300 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | TIME LIMIT EXCEEDED | 0 |
#2 | TIME LIMIT EXCEEDED | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | TIME LIMIT EXCEEDED | -- | 1 | details |
#2 | TIME LIMIT EXCEEDED | -- | 2 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Compiler report
input/code.cpp: In function 'int etsi(long int, std::vector<std::pair<long int, long int> >, long int, int*)': input/code.cpp:40:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(k<v.size()-1&&v.at(k+1).first==x){ ^
Code
/** To change this license header, choose License Headers in Project Properties.* To change this template file, choose Tools | Templates* and open the template in the editor.*//** File: main.cpp* Author: alex** Created on October 6, 2016, 9:19 PM*/#include <cstdlib>using namespace std;#include <iostream>#include <stack>#include <algorithm>#include <vector>/***/int etsi (long x,vector< pair<long,long> > v, long o , int y[]){long n=v.size();long k=0;for (long b = n/2; b >= 1; b /= 2) {while(k+b<n&&v.at(k+b).first<x){k+=b;}}if(k<v.size()-1&&v.at(k+1).first==x){k++;}while(o!=-1&&v.at(k)>=v.at(o)){k--;if(k<0){return 0;}}if(k<0){return 0;}if(v.at(k).first>x){return 0;}if(x-v.at(k).first*v.at(k).second<x) {return 1;}for (int i = v.at(k).second; i > 0; i--) {int pa= etsi(x-v.at(k).first*i,v,k,y);if(pa==1){return 1;}else{}}return 0;}int main(int argc, char** argv) {long n;cin >> n;long l[n];int y[100000000];long a;long j=0;vector< pair<long,long> > v;for (int i = 0; i < n; i++) {cin >> a;l[i]=a;}sort(l, l+n);a=l[0];long r=1;long f;for (int i = 1; i < n; i++) {f=l[i];if(f==a){r++;a=f;}else{pair <int,int> p=make_pair(a,r);v.push_back(p);j++;a=f;r=1;}}pair <int,int> p=make_pair(a,r);v.push_back(p);int i=1;while(etsi(i,v,-1,y)){i++;}cout << i;return 0;}
Test details
Test 1
Group: 1
Verdict: TIME LIMIT EXCEEDED
input |
---|
10 9 3 4 7 6 5 10 2 8 1 |
correct output |
---|
32 10 10 9 10 9 8 7 9 4 2 1 4 5 2... |
user output |
---|
(empty) |
Test 2
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 650 716 982 41 133 1000 876 92... |
correct output |
---|
3984 207 207 206 207 128 127 126 12... |
user output |
---|
(empty) |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 94703 47808 62366 31885 7091 8... |
correct output |
---|
399956 98676 98676 98675 98676 62994 ... |
user output |
---|
(empty) |