Submission #60968756
Source Code Expand
Copy
#include<bits/stdc++.h>#define TxtIO freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); freopen("error.txt","w", stderr) ;using namespace std;#include <ext/pb_ds/assoc_container.hpp>#include <ext/pb_ds/tree_policy.hpp>using namespace __gnu_pbds;#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>int f(vector<int> &v){int n=v.size();vector<map<int, int>> dp(n);int y=1;for(int i=0;i<n;i++){for(int j=0;j<i;j++){int u=1;if(dp[j].find(v[i]-v[j])!=dp[j].end()){u=dp[j][v[i]-v[j]];}int p=1+u;dp[i][v[i]-v[j]]=p;
#include<bits/stdc++.h> #define TxtIO freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); freopen("error.txt","w", stderr) ; using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> int f(vector<int> &v){ int n=v.size(); vector<map<int, int>> dp(n); int y=1; for(int i=0;i<n;i++){ for(int j=0;j<i;j++){ int u=1; if(dp[j].find(v[i]-v[j])!=dp[j].end()){ u=dp[j][v[i]-v[j]]; } int p=1+u; dp[i][v[i]-v[j]]=p; y=max(y,p); } } return y; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); vector<int> a[3001]; int n;cin>>n; for(int i=0;i<n;i++){ int x;cin>>x; a[x].push_back(i); } int r=1; for(int i=0;i<=3000;i++){ if(a[i].size()==0){ continue; } r=max(r,f(a[i])); } cout<<r<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Illuminate Buildings |
User | john_rigby |
Language | C++ 20 (gcc 12.2) |
Score | 350 |
Code Size | 1149 Byte |
Status | AC |
Exec Time | 1574 ms |
Memory | 214464 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 350 / 350 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
random_01.txt | AC | 6 ms | 3720 KB |
random_02.txt | AC | 3 ms | 3644 KB |
random_03.txt | AC | 1 ms | 3716 KB |
random_04.txt | AC | 1 ms | 3520 KB |
random_05.txt | AC | 6 ms | 3632 KB |
random_06.txt | AC | 3 ms | 3644 KB |
random_07.txt | AC | 1 ms | 3572 KB |
random_08.txt | AC | 1 ms | 3512 KB |
random_09.txt | AC | 7 ms | 3736 KB |
random_10.txt | AC | 5 ms | 3720 KB |
random_11.txt | AC | 1 ms | 3632 KB |
random_12.txt | AC | 1 ms | 3464 KB |
random_13.txt | AC | 6 ms | 3828 KB |
random_14.txt | AC | 5 ms | 3772 KB |
random_15.txt | AC | 2 ms | 4012 KB |
random_16.txt | AC | 1 ms | 3624 KB |
random_17.txt | AC | 6 ms | 3956 KB |
random_18.txt | AC | 5 ms | 3968 KB |
random_19.txt | AC | 1 ms | 3564 KB |
random_20.txt | AC | 2 ms | 3796 KB |
random_21.txt | AC | 1574 ms | 214464 KB |
random_22.txt | AC | 1494 ms | 205900 KB |
random_23.txt | AC | 1564 ms | 214060 KB |
random_24.txt | AC | 1 ms | 3796 KB |
random_25.txt | AC | 1 ms | 3488 KB |
sample_01.txt | AC | 1 ms | 3656 KB |
sample_02.txt | AC | 1 ms | 3576 KB |
sample_03.txt | AC | 1 ms | 3564 KB |