fork(1) download
  1. # include <iostream>
  2. # include <fstream>
  3. # include <sstream>
  4. # include <algorithm>
  5. # include <numeric>
  6. # include <cstdio>
  7. # include <cmath>
  8. # include <cstdlib>
  9. # include <cstring>
  10. # include <vector>
  11. # include <list>
  12. # include <set>
  13. # include <map>
  14. # include <stack>
  15. # include <queue>
  16. # include <deque>
  17.  
  18. using namespace std;
  19.  
  20. #define GI ({int t;scanf("%d",&t);t;})
  21. #define FOR(i,a,b) for(int i=a;i<b;i++)
  22. #define REP(i,n) FOR(i,0,n)
  23. #define pb push_back
  24. #define sz size()
  25. #define INF (int)1e9
  26. #define EPS LD(1e-9)
  27. #define DINF LD(1e50)
  28. #define MAXINT 1001
  29. #define MDINT 1000000007
  30. #define loop2(x,i,j,n,m) for(i=0;i<n;i++){for(j=0;j<m;j++){printf("%d ",x[i][j]);}printf("\n");}
  31. #define loop(x,i,n) for(i=0;i<n;i++){printf("%d ",x[i]);}printf("\n");
  32.  
  33. typedef long long LL;
  34. typedef unsigned long long ULL;
  35. typedef vector<int> VI;
  36. typedef vector<string> VS;
  37. typedef vector<vector<int> > VVI;
  38. typedef pair<int,int> PII;
  39. typedef double LD;
  40.  
  41. int main(){
  42. int a,t,i,j,k,n,max,store[2001][2],next,points,len;
  43. t = GI;
  44. REP(a,t){
  45. n = GI ;
  46. REP(i,n){scanf("%d%d",&store[i][0],&store[i][1]);}
  47.  
  48. REP(i,n){len[i]=1;points[i]=store[i][1];next[i]=-1;}
  49. for(i=n-1;i>=0;i--){
  50. for(j=i+1;j<n;j++){
  51. if(store[j]>store[i]){
  52. if(len[j]+1>len[i]){len[i]=len[j]+1;next[i]=j;points[i]=points[j]+store[i][1];}
  53. if(len[j]+1==len[i]){
  54. if(points[j]+store[i][1]>=points[i]){next[i]=j;points[i]=points[j]+store[i][1];}
  55. }
  56. }
  57. }
  58. }
  59. for(i=0,max=0,maxi=-1;i<n;i++){
  60. if(len[i]>max){maxi=i;max=len[i];}
  61. while(1){printf("%d ",maxi);maxi=next[maxi];if(maxi==-1)break;}printf("\n");
  62. }
  63. return 0;
  64. }
  65.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
2

6
1 3
2 3
6 3
4 20 
3 15
9 10
6
1 3
1 3
6 3
4 20
3 15
9 10
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:48: error: invalid types ‘int[int]’ for array subscript
prog.cpp:48: error: invalid types ‘int[int]’ for array subscript
prog.cpp:48: error: invalid types ‘int[int]’ for array subscript
prog.cpp:49: warning: name lookup of ‘i’ changed
prog.cpp:42: warning:   matches this ‘i’ under ISO standard rules
prog.cpp:46: warning:   matches this ‘i’ under old rules
prog.cpp:52: error: invalid types ‘int[int]’ for array subscript
prog.cpp:52: error: invalid types ‘int[int]’ for array subscript
prog.cpp:52: error: invalid types ‘int[int]’ for array subscript
prog.cpp:52: error: invalid types ‘int[int]’ for array subscript
prog.cpp:52: error: invalid types ‘int[int]’ for array subscript
prog.cpp:52: error: invalid types ‘int[int]’ for array subscript
prog.cpp:52: error: invalid types ‘int[int]’ for array subscript
prog.cpp:53: error: invalid types ‘int[int]’ for array subscript
prog.cpp:53: error: invalid types ‘int[int]’ for array subscript
prog.cpp:54: error: invalid types ‘int[int]’ for array subscript
prog.cpp:54: error: invalid types ‘int[int]’ for array subscript
prog.cpp:54: error: invalid types ‘int[int]’ for array subscript
prog.cpp:54: error: invalid types ‘int[int]’ for array subscript
prog.cpp:54: error: invalid types ‘int[int]’ for array subscript
prog.cpp:59: error: ‘maxi’ was not declared in this scope
prog.cpp:60: error: invalid types ‘int[int]’ for array subscript
prog.cpp:60: error: invalid types ‘int[int]’ for array subscript
prog.cpp:42: warning: unused variable ‘a’
prog.cpp:42: warning: unused variable ‘k’
prog.cpp:64: error: expected `}' at end of input
prog.cpp:43: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
prog.cpp:45: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
prog.cpp:46: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
stdout
Standard output is empty